sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function setAddressFormCheckout()
{
$this->show_payment_address_form = $this->isSubmitted('address.payment');
$this->show_shipping_address_form = $this->isSubmitted('address.shipping');
$actions = array(
'get_states' => true,
'add_address' => true,
... | Controls state of address forms (open/closed) | entailment |
protected function submitAddAddressCheckout()
{
$type = $this->getPosted('save_address', '', true, 'string');
if (empty($type)) {
return null;
}
$errors = $this->validateAddressCheckout($type);
if (empty($errors)) {
$this->addAddressCheckout($type);... | Saves a submitted address | entailment |
protected function loginCheckout()
{
$result = $this->user_action->login($this->getSubmitted('user'));
if (isset($result['user'])) {
$result = $this->cart_action->login($result['user'], $this->data_cart);
}
if (!empty($result['user'])) {
$this->redirect($res... | Log in a customer during checkout | entailment |
protected function validateCouponCheckout()
{
$price_rule_id = $this->getPosted('check_pricerule', null, true, 'integer');
if (empty($price_rule_id)) {
return null;
}
$code = $this->getSubmitted('data.pricerule_code', '');
if ($code === '') {
return... | Validates a coupon code | entailment |
protected function submitCartItemsCheckout()
{
$items = $this->getSubmitted('cart.items');
if (empty($items)) {
return null;
}
$errors = array();
foreach ($items as $sku => $item) {
$errors += $this->validateCartItemCheckout($sku, $item);
... | Applies an action to the cart items | entailment |
protected function setMessageFormCheckout($key, $message)
{
gplcart_array_set($this->data_form['messages'], $key, $this->format($message));
} | Sets an array of messages on the checkout form
@param string $key
@param string|array $message | entailment |
protected function updateCartQuantityCheckout($sku, array $item)
{
if (isset($this->data_cart['items'][$sku]['cart_id'])) {
$cart_id = $this->data_cart['items'][$sku]['cart_id'];
$this->cart->update($cart_id, array('quantity' => $item['quantity']));
}
} | Updates cart quantity
@param string $sku
@param array $item | entailment |
protected function validateCartItemCheckout($sku, $item)
{
$item += array(
'sku' => $sku,
'increment' => false,
'admin' => !empty($this->admin),
'user_id' => $this->order_user_id,
'store_id' => $this->order_store_id
);
$this->setSu... | Validates a cart item and returns possible errors
@param string $sku
@param array $item
@return array | entailment |
protected function deleteCartCheckout()
{
$cart_id = $this->getSubmitted('cart.action.delete');
if (!empty($cart_id)) {
$this->setSubmitted('cart.action.update', true);
$this->cart->delete($cart_id);
}
} | Deletes an item from the cart | entailment |
protected function submitOrderCheckout()
{
if (!$this->isPosted('save')) {
return null;
}
$errors = array();
foreach (array('payment', 'shipping') as $type) {
$address_errors = $this->validateAddressCheckout($type);
if (!empty($address_errors))... | Saves an order to the database | entailment |
protected function validateOrderCheckout()
{
if ($this->same_payment_address) {
$this->unsetSubmitted('address.payment');
}
$this->setSubmitted('update', array());
$this->setSubmitted('store_id', $this->store_id);
$this->setSubmitted('user_id', $this->order_user_... | Validates an array of submitted data before creating an order
@return array | entailment |
protected function addAddressCheckout($type)
{
$submitted = $this->getSubmitted("address.$type");
if ($this->{"show_{$type}_address_form"} && !empty($submitted)) {
$address_id = $this->address->add($submitted);
$this->setSubmitted("{$type}_address", $address_id);
... | Adds a submitted address
@param string $type | entailment |
protected function addOrderCheckout()
{
$submitted = $this->getSubmittedOrderCheckout();
$result = $this->order_action->add($submitted, array('admin' => $this->admin));
$this->finishOrderCheckout($result);
} | Adds a new order | entailment |
protected function finishOrderCheckout(array $result)
{
if ($this->admin === 'add') {
$this->finishAddOrderCheckout($result);
} else if ($this->admin === 'clone') {
$this->finishCloneOrderCheckout($result);
}
$this->redirect($result['redirect'], $result['mess... | Performs final tasks after an order has been created
@param array $result | entailment |
protected function finishAddOrderCheckout(array $result)
{
if (!empty($result['order']['order_id'])) {
$vars = array(
'@num' => $result['order']['order_id'],
'@name' => $result['order']['customer_name'],
'@status' => $this->order->getStatusName($r... | Performs final tasks after an order has been added for a user
@param array $result | entailment |
protected function finishCloneOrderCheckout(array $result)
{
if (!empty($result['order']['order_id'])) {
$log = array(
'user_id' => $this->uid,
'order_id' => $this->data_order['order_id'],
'text' => $this->text('Cloned into order #@num', array('@n... | Performs final tasks after an order has been cloned
@param array $result | entailment |
protected function getSubmittedOrderCheckout()
{
$submitted = $this->getSubmitted();
$submitted += $this->data_form['order'];
$submitted['cart'] = $this->data_cart;
$submitted['data']['user'] = array(
'ip' => $this->server->remoteAddr(),
'agent' => $this->ser... | Returns an array of prepared submitted order data
@return array | entailment |
protected function prepareSubmittedOrderComponentsCheckout(array &$submitted)
{
foreach ($submitted['data']['components'] as $id => &$component) {
if (!isset($component['price'])) {
continue;
}
if (empty($component['price'])) {
unset($sub... | Prepare submitted order components
@param array $submitted | entailment |
protected function prepareOrderComponentsCheckout($calculated)
{
$component_types = $this->order->getComponentTypes();
$components = array();
foreach ($calculated['components'] as $type => $component) {
$components[$type] = array(
'price' => $component['price'],... | Prepares an array of price rule components
@param array $calculated
@return array | entailment |
protected function setDataFormCheckout()
{
$form = $this->render('checkout/form', $this->data_form, true);
if ($this->isAjax()) {
$this->response->outputHtml($form);
}
$this->setData('checkout_form', $form);
} | Sets form on the checkout page | entailment |
public static function add($key, $path)
{
self::$_registeredNamespaces[$key] = true;
self::$_options['loader']->addPsr4($key, $path);
} | Add a namespace to the autoloader path.
@param string $key
@param string $path
@static | entailment |
public function setContext($context, array $options = array())
{
if (!isset($context)) {
$context = stream_context_create((array) $context, $options);
}
if (!is_resource($context)) {
throw new UnexpectedValueException('Stream context is not a valid resource');
... | Sets the context resource
@param resource|array $context
@param array $options
@return $this
@throws UnexpectedValueException | entailment |
public function setUri($uri)
{
if (!is_array($uri)) {
$uri = parse_url($uri);
}
$this->uri = $uri;
return $this;
} | Sets the request URI
@param string|array $uri
@return $this | entailment |
public function setSocket()
{
if (empty($this->uri['scheme'])) {
throw new OutOfBoundsException('Unknown URL scheme');
}
if ($this->uri['scheme'] === 'http') {
$port = 80;
$protocol = 'tcp';
} else if ($this->uri['scheme'] === 'https') {
... | Sets a socket depending on the current URI parameters
@return $this
@throws OutOfBoundsException
@throws UnexpectedValueException | entailment |
public function exec()
{
$this->response = '';
$errno = $errstr = null;
if (isset($this->context)) {
$this->stream = stream_socket_client($this->socket, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $this->context);
} else {
$this->stream = stream_s... | Open Internet or Unix domain socket connection and execute a query
@throws UnexpectedValueException
@return $this | entailment |
protected function getRequestBody()
{
if (is_array($this->data)) {
$this->data = http_build_query($this->data);
}
$this->prepareHeaders();
$path = isset($this->uri['path']) ? $this->uri['path'] : '/';
if (isset($this->uri['query'])) {
$path .= "?{$t... | Returns the request body
@return string | entailment |
protected function prepareHeaders()
{
if (!isset($this->headers['Content-Length'])) {
$content_length = strlen($this->data);
if ($content_length > 0 || $this->method === 'POST' || $this->method === 'PUT') {
$this->headers['Content-Length'] = $content_length;
... | Prepare request headers | entailment |
public function getFormattedResponse()
{
list($header, $data) = preg_split("/\r\n\r\n|\n\n|\r\r/", $this->response, 2);
$headers = preg_split("/\r\n|\n|\r/", $header);
$status = explode(' ', trim(reset($headers)), 3);
$result = array(
'status' => '',
'http' ... | Returns an array of formatted response
@return array | entailment |
public function request($url, array $options = array())
{
$options += array(
'data' => null,
'timeout' => 30,
'context' => null,
'method' => 'GET',
'headers' => array()
);
if ($options['method'] === 'POST' && empty($options['header... | Shortcut method to perform an HTTP request
@param string $url
@param array $options
@return array | entailment |
public function get($condition)
{
$result = null;
$this->hook->attach('collection.get.before', $condition, $result, $this);
if (isset($result)) {
return $result;
}
if (!is_array($condition)) {
$condition = array('collection_id' => $condition);
... | Loads a collection from the database
@param array|int|string $condition
@return array | entailment |
public function canDelete($collection_id)
{
$sql = 'SELECT collection_item_id FROM collection_item WHERE collection_id=?';
$result = $this->db->fetchColumn($sql, array($collection_id));
return empty($result);
} | Whether a collection can be deleted
@param integer $collection_id
@return boolean | entailment |
public function getTypes()
{
$handlers = $this->getHandlers();
$types = array();
foreach ($handlers as $handler_id => $handler) {
$types[$handler_id] = $handler['title'];
}
return $types;
} | Returns an array of collection type names keyed by a handler ID
@return array | entailment |
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('ApplicationConfig');
$allConnections = $libraryToConnMap = $configMap = array();
// Early return
if (!isset($config['datasource']['connections'])) {
return ne... | Create and return the datasource service.
@param ServiceLocatorInterface $serviceLocator
@return \PPI\Framework\DataSource\DataSource; | entailment |
public function display($tpl = '')
{
$tpl || $tpl = Url::pathInfo();
if($this->layout){
self::$content = $this->_getContent($tpl);
$content = $this->_getContent($this->layout);
}else
$content = $this->_getContent($tpl);
$this->addToken($content);
... | 模板显示
指定layout的情况下使用子模板模式,不指定直接显示当前模板 | entailment |
public function includeTpl($tpl)
{
foreach ($this->tplVar as $k => $v) $$k = $v;
require(Config::$viewDir . $tpl . '.php');
} | 模板文件中包含其他模板文件方法 | entailment |
private function _buildToken()
{
if (!Session::get($this->tokenName))
Session::set($this->tokenName, array());
$tokenKey = md5($_SERVER['REQUEST_URI']);
$tName = Session::get($this->tokenName);
if (isset($tName[$tokenKey])) // 相同页面不重复生成session
$tokenValue = $... | 创建表单令牌 | entailment |
public function index($product)
{
if (is_numeric($product)) {
$product = $this->product->get($product);
}
if (empty($product)) {
return false;
}
$indexed = 0;
$indexed += (int) $this->indexProduct($product);
$indexed += (int) $this->i... | Indexes a product
@param integer|array $product
@return boolean | entailment |
public function search($query, array $data)
{
$sql = 'SELECT si.entity_id';
if (!empty($data['count'])) {
$sql = 'SELECT COUNT(si.entity_id)';
}
$conditions = array($query, $data['language'], 'und', 'product');
$sql .= ' FROM search_index si
L... | Returns an array of suggested products for a given query
@param string $query
@param array $data
@return array | entailment |
protected function indexProduct(array $product)
{
$snippet = $this->search->getSnippet($product, 'und');
return $this->search->setIndex($snippet, 'product', $product['product_id'], 'und');
} | Adds the main product data to the search index
@param array $product
@return boolean | entailment |
protected function indexProductTranslations(array $product)
{
if (empty($product['translation'])) {
return false;
}
$indexed = 0;
foreach ($product['translation'] as $language => $translation) {
$translation += $product;
$snippet = $this->search-... | Adds product translations to the search index
@param array $product
@return boolean | entailment |
public function init($config)
{
$this->pdo = null;
$dns = '';
if (is_array($config)) {
$config += array('user' => null, 'password' => null);
$dns = "{$config['type']}:host={$config['host']};port={$config['port']};dbname={$config['name']}";
} else if (is_strin... | Set up database connection
@param mixed $config
@throws RuntimeException
@return $this | entailment |
public function query($sql)
{
$result = $this->pdo->query($sql);
$this->executed[] = $sql;
return $result;
} | Executes an SQL statement, returning a result set as a PDOStatement object
@param string $sql
@return \PDOStatement|false | entailment |
public function exec($sql)
{
$result = $this->pdo->exec($sql);
$this->executed[] = $sql;
return $result;
} | Execute an SQL statement and return the number of affected rows
@param string $sql
@return integer | entailment |
public function fetchColumn($sql, array $params = array(), $pos = 0)
{
return $this->run($sql, $params)->fetchColumn($pos);
} | Returns a single column
@param string $sql
@param array $params
@param integer $pos
@return mixed | entailment |
public function run($sql, array $params = array())
{
$sth = $this->pdo->prepare($sql);
foreach ($params as $key => $value) {
$key = is_numeric($key) ? $key + 1 : ":$key";
$sth->bindValue($key, $value);
}
$sth->execute($params);
$this->executed[] = $s... | Runs a SQL query with an array of placeholders
@param string $sql
@param array $params
@return \PDOStatement | entailment |
public function fetchColumnAll($sql, array $params = array(), $pos = 0)
{
return $this->run($sql, $params)->fetchAll(PDO::FETCH_COLUMN, $pos);
} | Returns a simple array of columns
@param string $sql
@param array $params
@param integer $pos
@return mixed | entailment |
public function fetch($sql, array $params, array $options = array())
{
$sth = $this->run($sql, $params);
$result = $sth->fetch(PDO::FETCH_ASSOC);
$this->prepareResult($result, $options);
return empty($result) ? array() : (array) $result;
} | Returns a single array indexed by column name
@param string $sql
@param array $params
@param array $options
@return array | entailment |
protected function prepareResult(&$data, array $options)
{
if (!empty($options['unserialize']) && !empty($data)) {
foreach ((array) $options['unserialize'] as $field) {
$data[$field] = empty($data[$field]) ? array() : unserialize($data[$field]);
}
}
} | Prepares a single result
@param mixed $data
@param array $options | entailment |
public function fetchAll($sql, array $params, array $options = array())
{
$result = $this->run($sql, $params)->fetchAll(PDO::FETCH_ASSOC);
$this->prepareResults($result, $options);
return empty($result) ? array() : (array) $result;
} | Returns an array of database records
@param string $sql
@param array $params
@param array $options
@return array | entailment |
protected function prepareResults(array &$results, array $options)
{
$reindexed = array();
foreach ($results as &$result) {
$this->prepareResult($result, $options);
if (!empty($options['index'])) {
$reindexed[$result[$options['index']]] = $result;
... | Prepares an array of results
@param array $results
@param array $options | entailment |
public function insert($table, array $data, $prepare = true)
{
if ($prepare) {
$data = $this->prepareInsert($table, $data);
}
if (empty($data)) {
return '0';
}
$keys = array_keys($data);
$fields = implode(',', $keys);
$values = ':' . ... | Performs an INSERT query
@param $table
@param array $data
@param bool $prepare
@return string | entailment |
public function update($table, array $data, array $conditions, $filter = true)
{
if ($filter) {
$data = $this->filterValues($table, $data);
}
if (empty($data)) {
return 0;
}
$farray = array();
foreach (array_keys($data) as $key) {
... | Performs a UPDATE query
@param $table
@param array $data
@param array $conditions
@param bool $filter
@return integer | entailment |
public function delete($table, array $conditions)
{
if (empty($conditions)) {
return 0;
}
$carray = array();
foreach (array_keys($conditions) as $key) {
$carray[] = "$key=:$key";
}
$sql = "DELETE FROM $table WHERE " . implode(' AND ', $carray... | Performs a DELETE query
@param string $table
@param array $conditions
@return integer | entailment |
public function prepareInsert($table, array $data)
{
$data += $this->getDefaultValues($table);
return $this->filterValues($table, $data);
} | Returns an array of prepared values ready to insert into the database
@param string $table
@param array $data
@return array | entailment |
public function getDefaultValues($table)
{
$scheme = $this->getScheme($table);
$values = array();
foreach ($scheme['fields'] as $name => $info) {
if (array_key_exists('default', $info)) {
$values[$name] = $info['default'];
continue;
}
... | Returns an array of default field values for the given table
@param string $table
@return array | entailment |
public function getScheme($table = null)
{
$default = (array) gplcart_config_get(GC_FILE_CONFIG_DATABASE);
$scheme = array_merge($this->scheme, $default);
if (isset($table)) {
if (empty($scheme[$table]['fields'])) {
throw new OutOfBoundsException("Database table ... | Returns an array of database scheme
@param string|null $table
@return array
@throws OutOfBoundsException | entailment |
protected function filterValues($table, array $data)
{
$scheme = $this->getScheme($table);
$values = array_intersect_key($data, $scheme['fields']);
if (empty($values)) {
return array();
}
foreach ($values as $field => &$value) {
if (!empty($scheme['... | Filters an array of data according to existing scheme for the given table
@param string $table
@param array $data
@return array | entailment |
public function tableExists($table)
{
$result = $this->query("SHOW TABLES LIKE " . $this->pdo->quote($table));
return $result->rowCount() > 0;
} | Check if a table already exists
@param string $table
@return bool | entailment |
public function import(array $tables)
{
foreach ($tables as $table => $data) {
if (!$this->query($this->getSqlCreateTable($table, $data))) {
throw new RuntimeException("Failed to import database table $table");
}
$alter = $this->getSqlAlterTable($table, ... | Creates tables using an array of scheme data
@param array $tables
@throws RuntimeException | entailment |
public function importScheme($table, array $scheme)
{
if ($this->tableExists($table)) {
throw new RuntimeException('Table already exists');
}
try {
$this->import($scheme);
} catch (Exception $ex) {
$this->deleteTable($table);
throw new... | Install a database table using the scheme
@param string $table
@param array $scheme
@throws RuntimeException | entailment |
protected function getSqlFields(array $fields)
{
$sql = array();
foreach ($fields as $name => $info) {
if (strpos($info['type'], 'text') !== false || $info['type'] === 'blob') {
unset($info['default']);
}
$string = "{$info['type']}";
... | Returns a SQL that describes table fields.
Used to create tables
@param array $fields
@return string | entailment |
public function listZone()
{
$this->actionListZone();
$this->setTitleListZone();
$this->setBreadcrumbListZone();
$this->setFilterListZone();
$this->setPagerListZone();
$this->setData('zones', $this->getListZone());
$this->outputListZone();
} | Displays the zone overview page | entailment |
public function setPagerListZone()
{
$options = $this->query_filter;
$options['count'] = true;
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->zone->getList($options)
);
return $this->data_limit = $this->setPager($pager);
... | Sets pager
@return array | entailment |
protected function getListZone()
{
$conditions = $this->query_filter;
$conditions['limit'] = $this->data_limit;
return $this->zone->getList($conditions);
} | Returns an array of zones
@return array | entailment |
public function editZone($zone_id = null)
{
$this->setZone($zone_id);
$this->setTitleEditZone();
$this->setBreadcrumbEditZone();
$this->setData('zone', $this->data_zone);
$this->setData('can_delete', $this->canDeleteZone());
$this->submitEditZone();
$this->o... | Displays the zone edit page
@param null|integer $zone_id | entailment |
protected function canDeleteZone()
{
return isset($this->data_zone['zone_id'])
&& $this->zone->canDelete($this->data_zone['zone_id'])
&& $this->access('zone_delete');
} | Whether the zone can be deleted
@return bool | entailment |
protected function setZone($zone_id)
{
$this->data_zone = array();
if (is_numeric($zone_id)) {
$this->data_zone = $this->zone->get($zone_id);
if (empty($this->data_zone)) {
$this->outputHttpStatus(404);
}
}
} | Sets a zone data
@param integer $zone_id | entailment |
protected function submitEditZone()
{
if ($this->isPosted('delete')) {
$this->deleteZone();
} else if ($this->isPosted('save') && $this->validateEditZone()) {
if (isset($this->data_zone['zone_id'])) {
$this->updateZone();
} else {
$... | Handles a submitted zone data | entailment |
protected function validateEditZone()
{
$this->setSubmitted('zone');
$this->setSubmittedBool('status');
$this->setSubmitted('update', $this->data_zone);
$this->validateComponent('zone');
return !$this->hasErrors();
} | Validates a submitted zone
@return bool | entailment |
protected function deleteZone()
{
$this->controlAccess('zone_delete');
if ($this->zone->delete($this->data_zone['zone_id'])) {
$this->redirect('admin/settings/zone', $this->text('Zone has been deleted'), 'success');
}
$this->redirect('', $this->text('Zone has not been d... | Deletes a zone | entailment |
protected function updateZone()
{
$this->controlAccess('zone_edit');
if ($this->zone->update($this->data_zone['zone_id'], $this->getSubmitted())) {
$this->redirect('admin/settings/zone', $this->text('Zone has been updated'), 'success');
}
$this->redirect('', $this->text... | Updates a zone | entailment |
protected function addZone()
{
$this->controlAccess('zone_add');
if ($this->zone->add($this->getSubmitted())) {
$this->redirect('admin/settings/zone', $this->text('Zone has been added'), 'success');
}
$this->redirect('', $this->text('Zone has not been added'), 'warning'... | Adds a new zone | entailment |
protected function setTitleEditZone()
{
if (isset($this->data_zone['zone_id'])) {
$title = $this->text('Edit %name', array('%name' => $this->data_zone['title']));
} else {
$title = $this->text('Add zone');
}
$this->setTitle($title);
} | Sets titles on the edit zone page | entailment |
protected function setBreadcrumbEditZone()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'text' => $this->text('Zones'),
'url' => $this->u... | Sets breadcrumbs on the edit zone page | entailment |
protected function setImage(array $data, $field_value_id = null)
{
if (!empty($data['images']) && !empty($field_value_id)) {
$this->file->delete(array('entity' => 'field_value', 'entity_id' => $field_value_id));
}
return $this->setImages($data, $this->file, 'field_value');
} | Sets a single image
@param array $data
@param null|int $field_value_id
@return bool | entailment |
protected function deleteLinked($field_value_id)
{
$this->db->delete('product_field', array('field_value_id' => $field_value_id));
$this->db->delete('field_value_translation', array('field_value_id' => $field_value_id));
$this->db->delete('file', array('entity' => 'field_value', 'entity_id' ... | Deletes all database records related to the field value ID
@param int $field_value_id | entailment |
protected function canDelete($field_value_id)
{
$sql = 'SELECT c.product_id
FROM product_field pf
LEFT JOIN cart c ON(pf.product_id = c.product_id)
WHERE pf.field_value_id=?';
$result = $this->db->fetchColumn($sql, array($field_value_id));
ret... | Whether the field value can be deleted
@param integer $field_value_id
@return boolean | entailment |
public function setInvokableClass($name, $invokableClass, $shared = null)
{
parent::setInvokableClass($name, $invokableClass, $shared);
if ($name != $invokableClass) {
$this->setAlias($invokableClass, $name);
}
return $this;
} | Override setInvokableClass().
Performs normal operation, but also auto-aliases the class name to the
service name. This ensures that providing the FQCN does not trigger an
abstract factory later.
@param string $name
@param string $invokableClass
@param null|bool $shared
@return RoutePluginManager | entailment |
public function validatePlugin($plugin)
{
if ($plugin instanceof RouteInterface) {
// we're okay
return;
}
throw new RuntimeException(sprintf(
'Plugin of type %s is invalid; must implement %s\RouteInterface',
(is_object($plugin) ? get_class($p... | Validate the plugin.
Checks that the filter loaded is either a valid callback or an instance
of FilterInterface.
@param mixed $plugin
@throws RuntimeException if invalid | entailment |
protected function createFromInvokable($canonicalName, $requestedName)
{
$invokable = $this->invokableClasses[$canonicalName];
if (!class_exists($invokable)) {
throw new RuntimeException(sprintf(
'%s: failed retrieving "%s%s" via invokable class "%s"; class does not exist... | Attempt to create an instance via an invokable class.
Overrides parent implementation by invoking the route factory,
passing $creationOptions as the argument.
@param string $canonicalName
@param string $requestedName
@throws Exception\RuntimeException If resolved class does not exist, or does not implement RouteInte... | entailment |
public function date(array $values)
{
if (count($values) != 1) {
$vars = array('@field' => $this->translation->text('Condition'));
return $this->translation->text('@field has invalid value', $vars);
}
$timestamp = strtotime(reset($values));
if (empty($timest... | Validates the date condition
@param array $values
@return boolean|string | entailment |
public static function validate($dataSource, $schema, $numPeekRows = 10, $csvDialect = null)
{
try {
$table = new static($dataSource, $schema, $csvDialect);
} catch (Exceptions\DataSourceException $e) {
return [new SchemaValidationError(SchemaValidationError::LOAD_FAILED, $e-... | @param DataSources\DataSourceInterface $dataSource
@param Schema $schema
@param int $numPeekRows
@return array of validation errors | entailment |
public function current()
{
if (count($this->castRows) > 0) {
$row = array_shift($this->castRows);
} else {
$row = $this->schema->castRow($this->dataSource->getNextLine());
foreach ($this->schema->fields() as $field) {
if ($field->unique()) {
... | called on each iteration to get the next row
does validation and casting on the row.
@return mixed[]
@throws Exceptions\FieldValidationException
@throws Exceptions\DataSourceException | entailment |
public static function deserializeObject(array $data)
{
return new static(
$data['type'],
$data['name'],
$data['description'],
isset($data['specUri']) ? $data['specUri'] : null,
isset($data['documentationUri']) ? $data['documentationUri'] : null
... | @param array $data
@return AuthenticationScheme | entailment |
public function submitCart($cart_action_model)
{
$this->setSubmitted('product');
$this->filterSubmitted(array('product_id'));
if ($this->isPosted('add_to_cart')) {
$this->validateAddToCart();
$this->addToCart($cart_action_model);
} else if ($this->isPosted('r... | Handles product cart submissions
@param \gplcart\core\models\CartAction $cart_action_model | entailment |
public function validateAddToCart()
{
$this->setSubmitted('user_id', $this->getCartUid());
$this->setSubmitted('store_id', $this->getStoreId());
$this->setSubmitted('quantity', $this->getSubmitted('quantity', 1));
$this->validateComponent('cart');
} | Validates adding a product to cart | entailment |
public function addToCart($cart_action_model)
{
$errors = $this->error();
if (empty($errors)) {
$submitted = $this->getSubmitted();
$result = $cart_action_model->add($submitted['product'], $submitted);
} else {
$result = array(
'redirect'... | Adds a product to the cart
@param \gplcart\core\models\CartAction $cart_action_model | entailment |
public function deleteFromCart($cart_action_model)
{
$result = $cart_action_model->delete($this->getSubmitted('cart_id'));
if (empty($result['quantity'])) {
$result['message'] = '';
}
if ($this->isAjax()) {
$result['modal'] = $this->getCartPreview();
... | Deletes a submitted cart item
@param \gplcart\core\models\CartAction $cart_action_model | entailment |
public function listBlog()
{
$this->setTitleListBlog();
$this->setBreadcrumbListBlog();
$this->setTotalListBlog();
$this->setPagerListBlog();
$this->setData('pages', $this->getPagesBlog());
$this->outputListBlog();
} | Page callback
Displays the blog page | entailment |
protected function setTotalListBlog()
{
$conditions = $this->query_filter;
$conditions['status'] = 1;
$conditions['count'] = true;
$conditions['blog_post'] = 1;
$conditions['store_id'] = $this->store_id;
return $this->data_total = (int) $this->page->getList($conditi... | Sets a total number of posts found
@return int | entailment |
protected function getPagesBlog()
{
$conditions = $this->query_filter;
$conditions['status'] = 1;
$conditions['blog_post'] = 1;
$conditions['limit'] = $this->data_limit;
$conditions['store_id'] = $this->store_id;
$list = (array) $this->page->getList($conditions);
... | Returns an array of blog posts
@return array | entailment |
protected function preparePagesBlog(array &$list)
{
foreach ($list as &$item) {
list($teaser, $body) = $this->explodeText($item['description']);
if ($body !== '') {
$item['teaser'] = strip_tags($teaser);
}
$this->setItemEntityUrl($item, arra... | Prepare an array of pages
@param array $list | entailment |
protected function setPagerListBlog()
{
$pager = array(
'total' => $this->data_total,
'query' => $this->query_filter,
'limit' => $this->configTheme('blog_limit', 20)
);
return $this->data_limit = $this->setPager($pager);
} | Sets pager
@return array | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$verbose = OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity();
$invoke = $input->getOption('invoke');
$sm = $this->getServiceManager()->get('ServiceManager');
$registeredService... | {@inheritdoc}
@throws \LogicException | entailment |
public function init(Request $request, $postType, $id, $subPostType)
{
// Lets validate if the post type exists and if so, continue.
$postTypeModel = $this->getPostType($postType);
if(!$postTypeModel){
$errorMessages = 'You are not authorized to do this.';
return $this->abort($errorMessages);
}
... | Display a single post | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$cacheDir = $this->getServiceManager()->getParameter('app.cache_dir');
$filesystem = $this->getServiceManager()->getService('filesystem');
if (!is_writable($cacheDir)) {
throw new \RuntimeException(sp... | {@inheritdoc} | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
if (!$this->checkRunStatus($input, $output)) {
return 0;
}
$limit = (int) $input->getOption('limit');
/** @var SettingsHelper $settingsHelper */
... | @param InputInterface $input
@param OutputInterface $output
@return int|null | entailment |
public function review(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateReview();
$this->validateBool('status');
$this->validateTextReview();
$this->validateCreatedReview();
$this->valida... | Performs full review data validation
@param array $submitted
@param array $options
@return array|boolean | entailment |
protected function validateReview()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->review->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Review'));
return... | Validates a review to be updated
@return boolean|null | entailment |
protected function validateTextReview()
{
$field = 'text';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating() && !isset($value)) {
$this->unsetSubmitted($field);
return null;
... | Validates a review text
@return boolean|null | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.