Sulu\Bundle\CategoryBundle\Entity\Category::addTranslation PHP Метод

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

public addTranslation ( Sulu\Bundle\CategoryBundle\Entity\CategoryTranslationInterface $translations )
$translations Sulu\Bundle\CategoryBundle\Entity\CategoryTranslationInterface
    public function addTranslation(CategoryTranslationInterface $translations)
    {
        $this->translations[] = $translations;
        return $this;
    }

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\Entity\Category::addTranslation