本文整理汇总了PHP中TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertySettable方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectAccess::isPropertySettable方法的具体用法?PHP ObjectAccess::isPropertySettable怎么用?PHP ObjectAccess::isPropertySettable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Extbase\Reflection\ObjectAccess
的用法示例。
在下文中一共展示了ObjectAccess::isPropertySettable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isPropertySettableWorksOnStdClass
/**
* @test
*/
public function isPropertySettableWorksOnStdClass()
{
$stdClassObject = new \stdClass();
$stdClassObject->property = 'foo';
$this->assertTrue(\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertySettable($stdClassObject, 'property'));
$this->assertFalse(\TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertySettable($stdClassObject, 'undefinedProperty'));
}
示例2: createDemandFromSettings
/**
* Creates a demand from given settings
*
* @param $settings
* @return ReservationDemand
*/
protected function createDemandFromSettings($settings)
{
/** @var ReservationDemand $demand */
$demand = $this->objectManager->get(ReservationDemand::class);
foreach ($settings as $propertyName => $propertyValue) {
if (empty($propertyValue)) {
continue;
}
switch ($propertyName) {
case 'maxItems':
$demand->setLimit($propertyValue);
break;
// all following fall through (see below)
// all following fall through (see below)
case 'periodType':
case 'periodStart':
case 'periodEndDate':
case 'periodDuration':
case 'search':
break;
default:
if (ObjectAccess::isPropertySettable($demand, $propertyName)) {
ObjectAccess::setProperty($demand, $propertyName, $propertyValue);
}
}
}
if (isset($settings['period'])) {
$demand->setPeriod($settings['period']);
if ($demand->getPeriod() === 'futureOnly' or $demand->getPeriod() == 'pastOnly') {
$timeZone = new \DateTimeZone(date_default_timezone_get());
$demand->setStartDate(new \DateTime('midnight', $timeZone));
}
}
if (isset($settings['order']) and is_string($settings['order'])) {
$demand->setOrder($settings['order']);
}
if (isset($settings['maxItems'])) {
$demand->setLimit($settings['maxItems']);
}
return $demand;
}
示例3: createDemandFromSettings
/**
* Create Demand from Settings
*
* @param array $settings
* @return \DWenzel\T3events\Domain\Model\Dto\EventDemand
*/
protected function createDemandFromSettings($settings)
{
$demand = $this->objectManager->get(CourseDemand::class);
$demand->setSortBy('headline');
foreach ($settings as $propertyName => $propertyValue) {
if (empty($propertyValue)) {
continue;
}
switch ($propertyName) {
case 'eventTypes':
$demand->setEventType($propertyValue);
break;
case 'venues':
$demand->setVenue($propertyValue);
break;
case 'maxItems':
$demand->setLimit($propertyValue);
break;
case 'genres':
$demand->setGenre($propertyValue);
break;
// all following fall through (see below)
// all following fall through (see below)
case 'periodType':
case 'periodStart':
case 'periodEndDate':
case 'periodDuration':
case 'search':
break;
default:
if (ObjectAccess::isPropertySettable($demand, $propertyName)) {
ObjectAccess::setProperty($demand, $propertyName, $propertyValue);
}
}
}
if (isset($settings['sortBy']) && isset($settings['sortDirection'])) {
$demand->setOrder($settings['sortBy'] . '|' . $settings['sortDirection']);
} else {
$demand->setOrder('headline');
}
if ($settings['period'] == 'specific') {
$demand->setPeriodType($settings['periodType']);
}
if (isset($settings['periodType']) and $settings['periodType'] != 'byDate') {
$demand->setPeriodStart($settings['periodStart']);
$demand->setPeriodDuration($settings['periodDuration']);
}
if ($settings['periodType'] == 'byDate') {
if ($settings['periodStartDate']) {
$demand->setStartDate($settings['periodStartDate']);
}
if ($settings['periodEndDate']) {
$demand->setEndDate($settings['periodEndDate']);
}
}
return $demand;
}
示例4: 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");
}
示例5: createAction
/**
* action create
*
* @param Reservation $newReservation
* @return void
*/
public function createAction(Reservation $newReservation)
{
if (!is_null($newReservation->getUid()) || $this->session instanceof SessionInterface && $this->session->has(self::SESSION_IDENTIFIER_RESERVATION)) {
$this->denyAccess();
return;
}
if ($contact = $newReservation->getContact()) {
$contact->setReservation($newReservation);
}
$newReservation->setStatus(Reservation::STATUS_DRAFT);
if ($newReservation->getContactIsParticipant() && is_object($contact)) {
$participant = new Person();
foreach (ObjectAccess::getGettableProperties($contact) as $propertyName => $propertyValue) {
if (ObjectAccess::isPropertySettable($participant, $propertyName)) {
ObjectAccess::setProperty($participant, $propertyName, $propertyValue);
}
}
$participant->setType(Person::PERSON_TYPE_PARTICIPANT);
$newReservation->addParticipant($participant);
$newReservation->getLesson()->addParticipant($participant);
}
$this->addFlashMessage($this->translate('message.reservation.create.success'));
$this->reservationRepository->add($newReservation);
$this->persistenceManager->persistAll();
$this->session->set(self::SESSION_IDENTIFIER_RESERVATION, $newReservation->getUid());
$this->redirect('edit', null, null, ['reservation' => $newReservation]);
}
示例6: createDemandFromSettings
/**
* Create demand from settings
*
* @param array $settings
* @return \CPSIT\T3eventsReservation\Domain\Model\Dto\PersonDemand
*/
protected function createDemandFromSettings($settings)
{
/**@var \CPSIT\T3eventsReservation\Domain\Model\Dto\PersonDemand $demand */
$demand = $this->objectManager->get(PersonDemand::class);
$demand->setTypes((string) Person::PERSON_TYPE_PARTICIPANT);
foreach ($settings as $propertyName => $propertyValue) {
if (empty($propertyValue)) {
continue;
}
switch ($propertyName) {
case 'maxItems':
$demand->setLimit($propertyValue);
break;
case 'category':
$demand->setCategories($propertyValue);
break;
// all following fall through (see below)
// all following fall through (see below)
case 'periodType':
case 'periodStart':
case 'periodEndDate':
case 'periodDuration':
case 'search':
break;
default:
if (ObjectAccess::isPropertySettable($demand, $propertyName)) {
ObjectAccess::setProperty($demand, $propertyName, $propertyValue);
}
}
}
if ($demand->getLessonPeriod() === 'futureOnly' or $demand->getLessonPeriod() === 'pastOnly') {
$timeZone = new \DateTimeZone(date_default_timezone_get());
$demand->setLessonDate(new \DateTime('midnight', $timeZone));
}
return $demand;
}