Skip to content

Commit 4267508

Browse files
authored
Merge pull request #20 from PackageFactory/countable-and-eager-translator
Countable and eager translator
2 parents 4200cac + 3eb9aaf commit 4267508

8 files changed

Lines changed: 43 additions & 8 deletions

File tree

Classes/Application/PseudoEnumProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
final class PseudoEnumProvider extends AbstractDataSource implements ProtectedContextAwareInterface, NodeTypePostprocessorInterface
2020
{
2121
/**
22-
* @Flow\Inject
22+
* @Flow\Inject(lazy=false)
2323
* @var Translator
2424
*/
2525
protected $translator;

Classes/Domain/Component/Component.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function getComponentArrayContent(): string
127127
/**
128128
* @Flow\Proxy(false)
129129
*/
130-
final class ' . $this->name->getSimpleComponentArrayName() . ' implements \IteratorAggregate
130+
final class ' . $this->name->getSimpleComponentArrayName() . ' implements \IteratorAggregate, \Countable
131131
{
132132
/**
133133
* @var array<int,' . $this->name->getSimpleInterfaceName() . '>|' . $this->name->getSimpleInterfaceName() . '[]
@@ -151,6 +151,11 @@ public function getIterator(): \ArrayIterator
151151
{
152152
return new \ArrayIterator($this->' . $this->name->getSimpleComponentArrayPropertyName() . ');
153153
}
154+
155+
public function count(): int
156+
{
157+
return count($this->' . $this->name->getSimpleComponentArrayPropertyName() . ');
158+
}
154159
}
155160
';
156161
}

Tests/Unit/Domain/Component/ComponentTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public function testGetComponentArrayContent(): void
419419
/**
420420
* @Flow\Proxy(false)
421421
*/
422-
final class MyNewComponents implements \IteratorAggregate
422+
final class MyNewComponents implements \IteratorAggregate, \Countable
423423
{
424424
/**
425425
* @var array<int,MyNewComponentInterface>|MyNewComponentInterface[]
@@ -443,6 +443,11 @@ public function getIterator(): \ArrayIterator
443443
{
444444
return new \ArrayIterator($this->myNewComponents);
445445
}
446+
447+
public function count(): int
448+
{
449+
return count($this->myNewComponents);
450+
}
446451
}
447452
',
448453
$this->subject->getComponentArrayContent()

Tests/Unit/Domain/Component/__snapshots__/ComponentGeneratorTest__generatesComponents with data set textWithArray__2.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use Neos\Flow\Annotations as Flow;
1010
/**
1111
* @Flow\Proxy(false)
1212
*/
13-
final class NewTexts implements \IteratorAggregate
13+
final class NewTexts implements \IteratorAggregate, \Countable
1414
{
1515
/**
1616
* @var array<int,NewTextInterface>|NewTextInterface[]
@@ -34,4 +34,9 @@ final class NewTexts implements \IteratorAggregate
3434
{
3535
return new \ArrayIterator($this->newTexts);
3636
}
37+
38+
public function count(): int
39+
{
40+
return count($this->newTexts);
41+
}
3742
}

Tests/Unit/Fixtures/Shared/Presentation/Component/Text/Texts.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* A list of texts
1212
* @Flow\Proxy(false)
1313
*/
14-
final class Texts implements \IteratorAggregate
14+
final class Texts implements \IteratorAggregate, \Countable
1515
{
1616
/**
1717
* @var array<int,TextInterface>|TextInterface[]
@@ -36,4 +36,9 @@ public function getIterator(): \ArrayIterator
3636
{
3737
return new \ArrayIterator($this->texts);
3838
}
39+
40+
public function count(): int
41+
{
42+
return count($this->texts);
43+
}
3944
}

Tests/Unit/Fixtures/Site/Presentation/Component/AnotherComponent/AnotherComponents.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* A list of anotherComponents
1212
* @Flow\Proxy(false)
1313
*/
14-
final class AnotherComponents implements \IteratorAggregate
14+
final class AnotherComponents implements \IteratorAggregate, \Countable
1515
{
1616
/**
1717
* @var array<int,AnotherComponentInterface>|AnotherComponentInterface[]
@@ -35,4 +35,9 @@ public function getIterator(): \ArrayIterator
3535
{
3636
return new \ArrayIterator($this->anotherComponents);
3737
}
38+
39+
public function count(): int
40+
{
41+
return count($this->anotherComponents);
42+
}
3843
}

Tests/Unit/Fixtures/Site/Presentation/Component/MyComponent/MyComponents.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* A list of myComponents
1212
* @Flow\Proxy(false)
1313
*/
14-
final class MyComponents implements \IteratorAggregate
14+
final class MyComponents implements \IteratorAggregate, \Countable
1515
{
1616
/**
1717
* @var array<int,MyComponentInterface>|MyComponentInterface[]
@@ -35,4 +35,9 @@ public function getIterator(): \ArrayIterator
3535
{
3636
return new \ArrayIterator($this->myComponents);
3737
}
38+
39+
public function count(): int
40+
{
41+
return count($this->myComponents);
42+
}
3843
}

Tests/Unit/Fixtures/Site/Presentation/Component/Text/Texts.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* A list of texts
1313
* @Flow\Proxy(false)
1414
*/
15-
final class Texts implements \IteratorAggregate
15+
final class Texts implements \IteratorAggregate, \Countable
1616
{
1717
/**
1818
* @var array<int,TextInterface>|TextInterface[]
@@ -36,4 +36,9 @@ public function getIterator(): \ArrayIterator
3636
{
3737
return new \ArrayIterator($this->texts);
3838
}
39+
40+
public function count(): int
41+
{
42+
return count($this->texts);
43+
}
3944
}

0 commit comments

Comments
 (0)