当前位置: 首页>>代码示例>>PHP>>正文


PHP ObjectAccess::isPropertySettable方法代码示例

本文整理汇总了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'));
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:10,代码来源:ObjectAccessTest.php

示例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;
 }
开发者ID:dwenzel,项目名称:t3events_reservation,代码行数:47,代码来源:BookingsController.php

示例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;
 }
开发者ID:dwenzel,项目名称:t3events_course,代码行数:63,代码来源:CourseBackendController.php

示例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");
 }
开发者ID:preinboth,项目名称:moox_news,代码行数:52,代码来源:AdministrationController.php

示例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]);
 }
开发者ID:dwenzel,项目名称:t3events_reservation,代码行数:33,代码来源:ReservationController.php

示例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;
 }
开发者ID:dwenzel,项目名称:t3events_reservation,代码行数:42,代码来源:ParticipantController.php


注:本文中的TYPO3\CMS\Extbase\Reflection\ObjectAccess::isPropertySettable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。