/** * Applies an array of fiters to query by calling each filter as method * on the query. * * @param AnDomainQuery $query Query Object * @param array $filters An array of filter */ public static function applyFilters($query, $filters) { foreach ($filters as $filter => $value) { $method = KInflector::variablize($filter); $value = KConfig::unbox($value); if (!is_array($value) || !is_numeric(key($value))) { $args = array($value); } else { $args = $value; } call_object_method($query, $method, $args); } }
/** * (non-PHPdoc) * @see ComSubscriptionsDomainPaymentGatewayAbstract::process() */ public function process(ComSubscriptionsDomainPaymentPayload $payload) { $options = new KConfig(); $options->append(array('description' => $payload->description)); $args = array($payload->getTotalAmount()); if ($payload->payment_method instanceof ComSubscriptionsDomainPaymentMethodToken) { $gateway = new Merchant_Billing_PaypalExpress($this->_gateway_config); $options->append($payload->payment_method->options); } else { $gateway = new Merchant_Billing_Paypal($this->_gateway_config); $ip = KRequest::get('server.REMOTE_ADDR', 'raw'); if (!$this->getService('koowa:filter.ip')->validate($ip) || strlen($ip) <= 7) { $ip = '127.0.0.1'; } $contact = $payload->payment_method->address; $options->append(array('order_id' => $payload->order_id, 'ip' => $ip, 'address' => array('address1' => $contact->address, 'zip' => $contact->zip, 'state' => $contact->state, 'city' => $contact->city, 'country' => $contact->country))); $args[] = $payload->payment_method->creditcard; } $method = 'purchase'; if ($payload->getRecurring()) { $method = 'recurring'; $options['occurrences'] = $payload->getRecurring()->frequency; $options['unit'] = $payload->getRecurring()->unit; $options['start_date'] = $payload->getRecurring()->start_date; } $args[] = KConfig::unbox($options); $gateway->post(array('TAXAMT' => $payload->tax_amount, 'ITEMAMT' => $payload->amount)); $response = call_object_method($gateway, $method, $args); $result = $response->success(); if (!$result) { $this->_logError($response); } return $result; }
/** * Iteratively calls the $method on the all the template objects * * @param string $method Method name * @param array $arguments Array of arguments * * @return mixed */ public function __call($method, $arguments) { foreach ($this->getObjects() as $object) { call_object_method($object, $method, $arguments); } return $this; }
/** * (non-PHPdoc) * @see KObjectDecorator::__call() */ public function __call($method, $arguments) { return call_object_method($this->getObject(), $method, $arguments); }
/** * If the missed method is implemented by the query object then delegate the call to the query object * * @see KObject::__call() */ public function __call($method, $arguments = array()) { $parts = KInflector::explode($method); if ($parts[0] == 'is' && isset($parts[1])) { $behavior = lcfirst(substr($method, 2)); return $this->_repository->hasBehavior($behavior); } //forward a call to the query if (method_exists($this->getQuery(), $method) || !$this->_repository->entityMethodExists($method)) { $result = call_object_method($this->getQuery(), $method, $arguments); if ($result instanceof AnDomainQuery) { $result = $this; } } else { $result = parent::__call($method, $arguments); } return $result; }
/** * Load a template helper. On Contrary to Nooku, it allows for any number of * argument than just an array * * @param string Name of the helper, dot separated including the helper function to call * @param mixed Parameters to be passed to the helper * * @return string Helper output */ public function renderHelper($identifier, $config = array()) { $args = func_get_args(); $identifier = array_shift($args); //Get the function to call based on the $identifier $parts = explode('.', $identifier); $function = array_pop($parts); $helper = implode('.', $parts); $helper = $this->getHelper($helper); //Call the helper function if (!is_callable(array($helper, $function))) { throw new KTemplateHelperException(get_class($helper) . '::' . $function . ' not supported.'); } return call_object_method($helper, $function, $args); }
/** * Overloaded call function to handle behaviors and forward all * calls to to the object regardless * * @param string The function name * @param array The function arguments * @return mixed The result of the function */ public function __call($method, $arguments) { $object = $this->getObject(); $parts = KInflector::explode($method); if ($parts[0] == 'is' && isset($parts[1])) { $behavior = lcfirst(substr($method, 2)); return !is_null($this->getRepository()->getBehavior($behavior)); } else { return call_object_method($object, $method, $arguments); } }
/** * Overloaded call function. * * @param string The function name * @param array The function arguments * * @return mixed The result of the function */ public function __call($method, $arguments) { $object = $this->getObject(); if ($object) { return call_object_method($object, $method, $arguments); } }
/** * Forward a request to all the objects in the object set * * @return mixed */ protected function _forward($type, $callable, $arguments = array(), $return = null) { settype($arguments, 'array'); $results = array(); $is_object = true; $is_boolean = true; foreach ($this as $object) { if ($type == 'method') { $value = call_object_method($object, $callable, $arguments); } else { if (empty($object->{$callable})) { continue; } else { $value = $object->{$callable}; } } if (!is_object($value)) { $is_object = false; } if (!is_bool($value)) { $is_boolean = false; } $results[] = $value; } if (empty($results)) { if ($return == 'array') { return array(); } elseif ($return == 'boolean') { return false; } } if ($is_object) { $set = new self(); foreach ($results as $value) { $set->insert($value); } $results = $set; } else { if ($is_boolean) { $results = array_unique($results); $value = true; foreach ($results as $result) { $value = $value && $result; } $results = $value; } } return $results; }