Author: Ross Riley (riley.ross@gmail.com)
Inheritance: implements Bolt\Storage\Field\Type\FieldTypeInterface, implements Bolt\Storage\Field\FieldInterface, use trait Bolt\Storage\CaseTransformTrait
コード例 #1
0
ファイル: SlugType.php プロジェクト: atiarda/bolt
 /**
  * {@inheritdoc}
  */
 public function persist(QuerySet $queries, $entity)
 {
     if ($entity->getSlug() === null) {
         // When no slug value is given, generate a pseudo-random reasonably unique one.
         $entity->setSlug('slug-' . md5(mt_rand()));
     }
     parent::persist($queries, $entity);
 }
コード例 #2
0
ファイル: DateType.php プロジェクト: atiarda/bolt
 /**
  * {@inheritdoc}
  */
 public function persist(QuerySet $queries, $entity, EntityManager $em = null)
 {
     $key = $this->mapping['fieldname'];
     $value = $entity->get($key);
     if (!$value instanceof \DateTime && $value !== null) {
         $value = new Carbon($value);
         $value::setToStringFormat('Y-m-d');
         $entity->set($key, $value);
     }
     parent::persist($queries, $entity, $em);
 }
コード例 #3
0
ファイル: TextType.php プロジェクト: nbehier/bolt
 /**
  * {@inheritdoc}
  */
 public function persist(QuerySet $queries, $entity)
 {
     $key = $this->mapping['fieldname'];
     $value = $entity->get($key);
     // Only sanitize when type is string, and not when the name is one of the Bolt-system ones.
     // Finally, we skip this if the value is empty-ish, e.g. '' or `null`.
     if ($this->mapping['type'] === 'string' && !in_array($key, ['username', 'status']) && !empty($value)) {
         $entity->set($key, $this->getSanitiser()->sanitise($value));
     }
     parent::persist($queries, $entity);
 }
コード例 #4
0
ファイル: TextType.php プロジェクト: bolt/bolt
 /**
  * {@inheritdoc}
  */
 public function persist(QuerySet $queries, $entity)
 {
     $key = $this->mapping['fieldname'];
     $value = $entity->get($key);
     // Note: The following section is commented out, because it was
     // sanitising fields when not desired. See #5789, for details.
     // Only sanitize when type is string, and not when the name is one of the Bolt-system ones.
     // Finally, we skip this if the value is empty-ish, e.g. '' or `null`.
     // if ($this->mapping['type'] === 'string' && !in_array($key, ['username', 'status']) && !empty($value)) {
     //     $entity->set($key, $this->getSanitiser()->sanitise($value));
     // }
     parent::persist($queries, $entity);
 }
コード例 #5
0
ファイル: ListTypeBase.php プロジェクト: zomars/bolt
 /**
  * {@inheritdoc}
  */
 public function persist(QuerySet $queries, $entity, EntityManager $em = null)
 {
     $key = $this->mapping['fieldname'];
     $value = $entity->get($key);
     if ($value !== null) {
         $value = $this->isJson($value) ? json_decode($value, true) : $value;
         // Remove elements that are not important for storage.
         foreach ($value as &$v) {
             unset($v['id']);
             unset($v['order']);
             unset($v['progress']);
             unset($v['element']);
         }
     }
     $entity->set($key, $value);
     parent::persist($queries, $entity, $em);
 }
コード例 #6
0
ファイル: RepeaterType.php プロジェクト: robbert-vdh/bolt
 /**
  * The set method gets called directly by a new entity builder. For this field we never want to allow
  * null values, rather we want an empty collection so this overrides the default and handles that.
  *
  * @param object $entity
  * @param mixed  $val
  */
 public function set($entity, $val)
 {
     if ($val === null) {
         $val = new RepeatingFieldCollection($this->em, $this->mapping);
     }
     return parent::set($entity, $val);
 }
コード例 #7
0
ファイル: HtmlType.php プロジェクト: bolt/bolt
 public function hydrate($data, $entity)
 {
     parent::hydrate($data, $entity);
 }