/** * Returns the internal dependency injector */ public function getDI() { if (!$this->_dependencyInjector) { $this->_dependencyInjector = DependencyInjection::getDefault(); } return $this->_dependencyInjector; }
/** * Returns the internal dependency injector */ public function getDI() { if (!is_object($this->_dependencyInjector)) { $this->_dependencyInjector = DependencyInjection::getDefault(null); } return $this->_dependencyInjector; }
/** * Returns the internal dependency injector */ public function getDI() { if (!is_object($this->_dependencyInjector)) { $this->_dependencyInjector = \WpPepVN\DependencyInjection::getDefault(); if (!is_object($this->_dependencyInjector)) { throw new Exception("A dependency injection object is required to access the 'url' service"); } } return $this->_dependencyInjector; }
/** * Internally gets the request dispatcher */ public static function getDI() { if (!is_object(self::$_dependencyInjector)) { self::$_dependencyInjector = DependencyInjection::getDefault(null); } return self::$_dependencyInjector; }
/** * Gets the a value to validate in the array/object data source * * @param string field * @return mixed */ public function getValue($field) { $entity = $this->_entity; /** * If the entity is an object use it to retrieve the values */ if (is_object($this->_entity)) { $method = "get" . $field; if (method_exists($entity, $method)) { $value = $entity->{$method}(); } else { if (method_exists($entity, "readAttribute")) { $value = $entity->readAttribute($field); } else { if (isset($entity->{$field})) { $value = $entity->{$field}; } else { $value = null; } } } return $value; } $data = $this->_data; if (!is_array($data) && !is_object($data)) { throw new Exception("There is no data to validate"); } /** * Check if there is a calculated value */ //$values = $this->_values; if (isset($this->_values[$field])) { return $this->_values[$field]; } $value = null; if (is_array($data)) { if (isset($data[$field])) { $value = $data[$field]; } } else { if (is_object($data)) { if (isset($data->{$field})) { $value = $data->{$field}; } } } if (is_null($value)) { return null; } //$filters = $this->_filters; if (is_array($this->_filters)) { //if fetch fieldFilters, filters[field] if (isset($this->_filters[$field])) { if ($this->_filters[$field]) { $dependencyInjector = $this->getDI(); if (!is_object($dependencyInjector)) { $dependencyInjector = DependencyInjection::getDefault(); if (!is_object($dependencyInjector)) { throw new Exception("A dependency injector is required to obtain the 'filter' service"); } } $filterService = $dependencyInjector->getShared("filter"); if (!is_object($filterService)) { throw new Exception("Returned 'filter' service is invalid"); } return $filterService->sanitize($value, $this->_filters[$field]); } } } /** * Cache the calculated value */ $this->_values[$field] = $value; return $value; }