/** * @param Property|string $property * @param bool $blnFromDataContainer * @return $this */ public function removeProperty($property, $blnFromDataContainer = true) { list($strName, $objProperty) = Property::argument($this, $property); if ($objProperty !== null) { unset($this->arrProperties[$strName]); unset($this->definition['fields'][$strName]); foreach ($this->getPalettes() as $strName => $objPalette) { $objPalette->removeProperty($strName); } foreach ($this->getSubPalettes() as $strName => $objSubPalette) { $objSubPalette->removeProperty($strName); } if (in_array($strName, $this->definition['palettes']['__selector__'])) { $intKey = array_search($strName, $this->definition['palettes']['__selector__']); unset($this->definition['palettes']['__selector__'][$intKey]); $this->definition['palettes']['__selector__'] = array_values($this->definition['palettes']['__selector__']); } } return $this; }
/** * Move property to new position * * @param Property|string $property * @param string $strLegend * @param null $reference * @param int $intPosition * * @return $this */ public function moveProperty($property, $strLegend = 'default', $reference = null, $intPosition = Definition::LAST) { list($strName, $objProperty) = Property::argument($this, $property); if (!$this->hasLegend($strLegend)) { $this->createLegend($strLegend); } /** @var \DcaTools\Definition\Property $objProperty */ if ($objProperty === null) { if ($this->hasProperty($strName)) { $objProperty = $this->getProperty($strName); if ($objProperty->getParent() != $this) { $objProperty->getParent()->removeProperty($objProperty); $this->getLegend($strLegend)->addProperty($objProperty); } } else { $objProperty = $this->getDataContainer()->getProperty($this); $this->getLegend($strLegend)->addProperty($objProperty); } } elseif ($objProperty->getParent() != $this && !$this->getLegend($strLegend)->hasProperty($strName)) { $objProperty->getParent()->removeProperty($objProperty); $this->getLegend($strLegend)->addProperty($objProperty); } $this->getLegend($strLegend)->moveProperty($objProperty, $reference, $intPosition); return $this; }
/** * Move property to new position * * @param Property|string $property * @param null $reference * @param $intPosition * @return $this */ public function moveProperty($property, $reference = null, $intPosition = Definition::LAST) { /** @var Property $objProperty */ list($strName, $objProperty) = Property::argument($this, $property, false); $this->requireSameDataContainer($objProperty); if ($objProperty->getParent() instanceof DataContainer) { if ($this != $objProperty->getParent()) { $objProperty = clone $objProperty; $objProperty->setParent($this); } } elseif ($objProperty->getParent() !== null && $this !== $objProperty->getParent()) { $objProperty->getParent()->remove(); } if ($this->hasProperty($strName)) { unset($this->arrProperties[$strName]); $this->addAtPosition($this->arrProperties, $objProperty, $reference, $intPosition); $this->updateDefinition(); } else { $this->addProperty($objProperty, $reference, $intPosition); } return $this; }