Sulu\Bundle\CategoryBundle\Api\Category::toArray PHP Метод

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

Returns an array representation of the object.
public toArray ( ) : array
Результат array
    public function toArray()
    {
        return ['id' => $this->getId(), 'key' => $this->getKey(), 'name' => $this->getName(), 'meta' => $this->getMeta(), 'defaultLocale' => $this->getDefaultLocale(), 'creator' => $this->getCreator(), 'changer' => $this->getChanger(), 'created' => $this->getCreated(), 'changed' => $this->getChanged()];
    }

Usage Example

Пример #1
0
 public function testGetContentData()
 {
     $categoryEntity1 = new CategoryEntity();
     $categoryTranslation1 = new CategoryTranslationEntity();
     $categoryTranslation1->setLocale('en');
     $categoryTranslation1->setTranslation('Category 1');
     $categoryEntity1->addTranslation($categoryTranslation1);
     $categoryEntity2 = new CategoryEntity();
     $categoryTranslation2 = new CategoryTranslationEntity();
     $categoryTranslation2->setLocale('en');
     $categoryTranslation2->setTranslation('Category 2');
     $categoryEntity2->addTranslation($categoryTranslation2);
     $category1 = new Category($categoryEntity1, 'en');
     $category2 = new Category($categoryEntity2, 'en');
     $categoryManager = $this->prophesize(CategoryManagerInterface::class);
     $categoryManager->findByIds([1, 2])->willReturn([$categoryEntity1, $categoryEntity2]);
     $categoryManager->getApiObjects([$categoryEntity1, $categoryEntity2], 'de')->willReturn([$category1, $category2]);
     $categoryList = new CategoryList($categoryManager->reveal(), '');
     $structure = $this->prophesize(StructureInterface::class);
     $structure->getLanguageCode()->willReturn('de');
     $property = $this->prophesize(Property::class);
     $property->getValue()->willReturn([1, 2]);
     $property->getStructure()->willReturn($structure->reveal());
     $result = $categoryList->getContentData($property->reveal());
     $this->assertEquals([$category1->toArray(), $category2->toArray()], $result);
     $categoryManager->findByIds([1, 2])->shouldBeCalled();
     $categoryManager->getApiObjects([$categoryEntity1, $categoryEntity2], 'de')->shouldBeCalled();
 }
All Usage Examples Of Sulu\Bundle\CategoryBundle\Api\Category::toArray