Skip to content

Commit

Permalink
Merge pull request #20 from PackageFactory/countable-and-eager-transl…
Browse files Browse the repository at this point in the history
…ator

Countable and eager translator
  • Loading branch information
nezaniel authored Jul 20, 2021
2 parents 4200cac + 3eb9aaf commit 4267508
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Classes/Application/PseudoEnumProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
final class PseudoEnumProvider extends AbstractDataSource implements ProtectedContextAwareInterface, NodeTypePostprocessorInterface
{
/**
* @Flow\Inject
* @Flow\Inject(lazy=false)
* @var Translator
*/
protected $translator;
Expand Down
7 changes: 6 additions & 1 deletion Classes/Domain/Component/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function getComponentArrayContent(): string
/**
* @Flow\Proxy(false)
*/
final class ' . $this->name->getSimpleComponentArrayName() . ' implements \IteratorAggregate
final class ' . $this->name->getSimpleComponentArrayName() . ' implements \IteratorAggregate, \Countable
{
/**
* @var array<int,' . $this->name->getSimpleInterfaceName() . '>|' . $this->name->getSimpleInterfaceName() . '[]
Expand All @@ -151,6 +151,11 @@ public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->' . $this->name->getSimpleComponentArrayPropertyName() . ');
}
public function count(): int
{
return count($this->' . $this->name->getSimpleComponentArrayPropertyName() . ');
}
}
';
}
Expand Down
7 changes: 6 additions & 1 deletion Tests/Unit/Domain/Component/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public function testGetComponentArrayContent(): void
/**
* @Flow\Proxy(false)
*/
final class MyNewComponents implements \IteratorAggregate
final class MyNewComponents implements \IteratorAggregate, \Countable
{
/**
* @var array<int,MyNewComponentInterface>|MyNewComponentInterface[]
Expand All @@ -443,6 +443,11 @@ public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->myNewComponents);
}
public function count(): int
{
return count($this->myNewComponents);
}
}
',
$this->subject->getComponentArrayContent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use Neos\Flow\Annotations as Flow;
/**
* @Flow\Proxy(false)
*/
final class NewTexts implements \IteratorAggregate
final class NewTexts implements \IteratorAggregate, \Countable
{
/**
* @var array<int,NewTextInterface>|NewTextInterface[]
Expand All @@ -34,4 +34,9 @@ final class NewTexts implements \IteratorAggregate
{
return new \ArrayIterator($this->newTexts);
}

public function count(): int
{
return count($this->newTexts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* A list of texts
* @Flow\Proxy(false)
*/
final class Texts implements \IteratorAggregate
final class Texts implements \IteratorAggregate, \Countable
{
/**
* @var array<int,TextInterface>|TextInterface[]
Expand All @@ -36,4 +36,9 @@ public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->texts);
}

public function count(): int
{
return count($this->texts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* A list of anotherComponents
* @Flow\Proxy(false)
*/
final class AnotherComponents implements \IteratorAggregate
final class AnotherComponents implements \IteratorAggregate, \Countable
{
/**
* @var array<int,AnotherComponentInterface>|AnotherComponentInterface[]
Expand All @@ -35,4 +35,9 @@ public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->anotherComponents);
}

public function count(): int
{
return count($this->anotherComponents);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* A list of myComponents
* @Flow\Proxy(false)
*/
final class MyComponents implements \IteratorAggregate
final class MyComponents implements \IteratorAggregate, \Countable
{
/**
* @var array<int,MyComponentInterface>|MyComponentInterface[]
Expand All @@ -35,4 +35,9 @@ public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->myComponents);
}

public function count(): int
{
return count($this->myComponents);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* A list of texts
* @Flow\Proxy(false)
*/
final class Texts implements \IteratorAggregate
final class Texts implements \IteratorAggregate, \Countable
{
/**
* @var array<int,TextInterface>|TextInterface[]
Expand All @@ -36,4 +36,9 @@ public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->texts);
}

public function count(): int
{
return count($this->texts);
}
}

0 comments on commit 4267508

Please sign in to comment.