本文整理汇总了PHP中TYPO3\CMS\Extbase\Reflection\ObjectAccess::getSettablePropertyNames方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::getSettablePropertyNames方法的具体用法?PHP ObjectAccess::getSettablePropertyNames怎么用?PHP ObjectAccess::getSettablePropertyNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Extbase\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::getSettablePropertyNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: supportsChainingInAllSettersWithFakeNullArgument
/**
* @test
*/
public function supportsChainingInAllSettersWithFakeNullArgument()
{
$asset = Asset::getInstance();
$settableProperties = ObjectAccess::getSettablePropertyNames($asset);
foreach ($settableProperties as $propertyName) {
$setter = 'set' . ucfirst($propertyName);
$asset = $asset->{$setter}(NULL);
$this->assertInstanceOf('FluidTYPO3\\Vhs\\Asset', $asset, 'The ' . $setter . ' method does not support chaining');
}
}
示例2: getSettablePropertyNamesReturnsPropertyNamesOfStdClass
/**
* @test
*/
public function getSettablePropertyNamesReturnsPropertyNamesOfStdClass()
{
$stdClassObject = new \stdClass();
$stdClassObject->property = 'string1';
$stdClassObject->property2 = NULL;
$settablePropertyNames = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getSettablePropertyNames($stdClassObject);
$expectedPropertyNames = array('property', 'property2');
$this->assertEquals($expectedPropertyNames, $settablePropertyNames, 'getSettablePropertyNames returns not all settable properties.');
}
示例3: cloneNewsAction
/**
* action clone news
*
* @param \int $uid
* @return void
*/
public function cloneNewsAction($uid = 0)
{
if ($uid > 0) {
$defaultStorageFields = array("categories", "contentElements", "relatedFiles", "relatedLinks", "media", "falMedia", "falRelatedFiles");
$testedStorageFields = array("categories");
$storageClasses = array("TYPO3\\CMS\\Extbase\\Persistence\\Generic\\LazyObjectStorage");
$original = $this->newsRepository->findByUid($uid, FALSE);
$clone = $this->objectManager->create('Tx_MooxNews_Domain_Model_News');
// $product = source object
$properties = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getSettablePropertyNames($original);
foreach ($properties as $name) {
$value = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($original, $name);
if (!in_array($name, $defaultStorageFields) && (!is_object($value) || is_object($value) && !in_array(get_class($value), $storageClasses))) {
\TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($clone, $name, $value);
}
}
foreach ($properties as $name) {
$value = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($original, $name);
if (in_array($name, $defaultStorageFields) && in_array($name, $testedStorageFields) || !in_array($name, $defaultStorageFields) && is_object($value) && in_array(get_class($value), $storageClasses)) {
$getCall = "get" . ucfirst($name);
$setCall = "get" . ucfirst($name);
if (method_exists($original, $getCall)) {
$objects = $original->{$getCall}();
if (method_exists($clone->{$getCall}(), "attach")) {
if (count($objects)) {
foreach ($objects as $object) {
if (\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertySettable($object, "uid")) {
//$object->setUid(NULL);
}
$clone->{$getCall}()->attach($object);
}
}
} elseif (method_exists($clone, $setCall)) {
$clone->{$setCall}($objects);
}
}
}
}
$clone->setTitle($original->getTitle() . " [Kopie]");
$clone->setHidden(1);
$this->newsRepository->add($clone);
$this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface')->persistAll();
$this->flashMessageContainer->add('', 'Eintrag wurde dupliziert', \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
}
$this->redirect("index");
}