getCategoriesFunction() публичный Метод

If parentKey is set, only the children of the category which is assigned to the given key are returned.
public getCategoriesFunction ( string $locale, string $parentKey = null ) : array
$locale string
$parentKey string key of parent category
Результат array
Пример #1
0
 /**
  * @dataProvider getProvider
  */
 public function testGet($categoryData, $locale = 'en', $parent = null, $depth = null)
 {
     $categoryEntities = [];
     $categoryApis = [];
     foreach ($categoryData as $category) {
         $categoryEntities[] = $this->createCategoryEntity($category);
         $categoryApis[] = $this->createCategoryApi($category);
     }
     $manager = $this->prophesize(CategoryManagerInterface::class);
     if (null === $parent) {
         $manager->find(null, null)->shouldBeCalled()->willReturn($categoryEntities);
     } else {
         $manager->findChildren($parent)->shouldBeCalled()->willReturn($categoryEntities);
     }
     $manager->getApiObjects($categoryEntities, $locale)->shouldBeCalled()->willReturn($categoryApis);
     $serializer = $this->prophesize(SerializerInterface::class);
     $serializer->serialize($categoryApis, 'array', Argument::type(SerializationContext::class))->shouldBeCalled()->willReturn($categoryData);
     $requestHandler = $this->prophesize(CategoryRequestHandlerInterface::class);
     $extension = new CategoryTwigExtension($manager->reveal(), $requestHandler->reveal(), $serializer->reveal(), $this->getMemoizeCache());
     $this->assertEquals($categoryData, $extension->getCategoriesFunction($locale, $parent, $depth));
 }