/** * @param Palette $objPalette * @param ModelInterface $objModel * @param bool $blnRecursive */ public function __construct(Palette $objPalette, ModelInterface $objModel, $blnRecursive = true) { $this->objModel = $objModel; $this->objPalette = $objPalette; $this->objIterator = $this->objPalette->getIterator(); $this->blnRecursive = $blnRecursive; }
public function testExtend() { $objPalette = $this->objPalette->getDataContainer()->createPalette('second'); $objPalette->extend($this->objPalette); $this->assertEquals($GLOBALS['TL_DCA']['tl_test']['palettes']['default'], $GLOBALS['TL_DCA']['tl_test']['palettes']['second']); $objPalette->createProperty('final'); $this->assertNotEquals($GLOBALS['TL_DCA']['tl_test']['palettes']['default'], $GLOBALS['TL_DCA']['tl_test']['palettes']['second']); }
/** * Get active sub palettes * * @param Palette $objPalette * @param ModelInterface $objModel * * @return \DcaTools\Definition\SubPalette[] */ public static function getActiveSubPalettesFor(Palette $objPalette, ModelInterface $objModel) { $arrSubPalettes = array(); foreach ($objPalette->getSelectors() as $objProperty) { $objSubPalette = static::getActivePropertySubPalette($objProperty, $objModel); if ($objSubPalette !== null) { $arrSubPalettes[$objSubPalette->getName()] = $objSubPalette; } } return $arrSubPalettes; }
/** * Extend an existing node of the same type * * @param Palette|string $palette * * @return $this * * @throws \RuntimeException */ public function extend($palette) { list($strName, $objPalette) = Palette::argument($this->getDataContainer(), $palette); /** @var Palette $objPalette */ foreach ($objPalette->getLegends() as $strName => $objLegend) { if (!$this->hasLegend($strName)) { $this->createLegend($strName); } $legend = $this->getLegend($strName); /** @var Property $property */ foreach ($objLegend as $property) { if (!$legend->hasProperty($property)) { $legend->addProperty($property); } } } $this->updateDefinition(); return $this; }
/** * @param string|Palette $palette * * @return $this */ public function removePalette($palette) { list($strName) = Palette::argument($this, $palette); if ($this->hasPalette($strName)) { unset($this->arrPalettes[$strName]); unset($this->definition['palettes'][$strName]); } return $this; }