Ejemplo n.º 1
0
 /**
  * Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field
  * on this object.
  *
  * @param string $field
  * @return string Casting helper
  */
 public function castingHelper($field)
 {
     $specs = $this->config()->casting;
     if (isset($specs[$field])) {
         return $specs[$field];
     } elseif ($this->failover) {
         return $this->failover->castingHelper($field);
     }
 }
 /**
  * @param  string $field
  * @return string|null
  */
 public function castingHelper($field)
 {
     $castings = $this->obj->getCastings();
     if (isset($castings[$field])) {
         return $castings[$field];
     } else {
         return parent::castingHelper($field);
     }
 }
Ejemplo n.º 3
0
	/**
	 * Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field
	 * on this object.
	 *
	 * @param string $field
	 * @return string
	 */
	public function castingHelper($field) {
		if($this->hasMethod('db') && $fieldSpec = $this->db($field)) {
			return $fieldSpec;
		}

		$specs = Config::inst()->get(get_class($this), 'casting');
		if(isset($specs[$field])) return $specs[$field];

		if($this->failover) return $this->failover->castingHelper($field);
	}
Ejemplo n.º 4
0
 /**
  * Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field
  * on this object.
  *
  * @param string $field
  * @return string
  */
 public function castingHelper($field)
 {
     if ($this->hasMethod('db') && ($fieldSpec = $this->db($field))) {
         return $fieldSpec;
     }
     $specs = Object::combined_static(get_class($this), 'casting');
     if (isset($specs[$field])) {
         return $specs[$field];
     }
     if ($this->failover) {
         return $this->failover->castingHelper($field);
     }
 }
Ejemplo n.º 5
0
    /**
     * Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field
     * on this object.
     *
     * @param string $field
     * @return string
     */
    public function castingHelper($field)
    {
        if ($this->hasMethod('db') && ($fieldSpec = $this->db($field))) {
            Deprecation::notice('4.0', 'ViewableData::castingHelper() will no longer extract casting information "db". Please override
				castingHelper in your ViewableData subclass.', Deprecation::SCOPE_GLOBAL);
            return $fieldSpec;
        }
        $specs = Config::inst()->get(get_class($this), 'casting');
        if (isset($specs[$field])) {
            return $specs[$field];
        }
        if ($this->failover) {
            return $this->failover->castingHelper($field);
        }
    }
Ejemplo n.º 6
0
 public function castingHelper($field)
 {
     // Allows db to act as implicit casting override
     if ($fieldSpec = $this->db($field)) {
         return $fieldSpec;
     }
     return parent::castingHelper($field);
 }
Ejemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function castingHelper($field)
 {
     if ($fieldSpec = $this->db($field)) {
         return $fieldSpec;
     }
     // many_many_extraFields aren't presented by db(), so we check if the source query params
     // provide us with meta-data for a many_many relation we can inspect for extra fields.
     $queryParams = $this->getSourceQueryParams();
     if (!empty($queryParams['Component.ExtraFields'])) {
         $extraFields = $queryParams['Component.ExtraFields'];
         if (isset($extraFields[$field])) {
             return $extraFields[$field];
         }
     }
     return parent::castingHelper($field);
 }