sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function setDataRatingEditReview() { $options = array( 'product' => $this->data_product, 'review' => $this->getData('review'), 'unvote' => $this->config('rating_unvote', 1) ); $this->setData('rating', $this->render('common/rating/edit', $options...
Sets rating widget
entailment
protected function validateEditReview() { $this->setSubmitted('review'); $this->filterSubmitted(array('text', 'rating')); $this->setSubmitted('user_id', $this->uid); $this->setSubmitted('update', $this->data_review); $this->setSubmitted('product_id', $this->data_product['prod...
Validates an array of submitted review data @return bool
entailment
protected function updateReview() { $submitted = $this->getSubmitted(); if ($this->review->update($this->data_review['review_id'], $submitted)) { $message = $this->text('Review has been updated'); if (empty($submitted['status'])) { $message = $this->text('R...
Updates a submitted review
entailment
protected function addReview() { $submitted = $this->getSubmitted(); $added = $this->review->add($submitted); if (empty($added)) { $message = $this->text('Review has not been added'); $this->redirect('', $message, 'warning'); } $message = $this->text...
Adds a submitted review
entailment
protected function deleteReview() { if (!$this->canDeleteReview()) { $message = $this->text('Unable to delete'); $this->redirect("product/{$this->data_product['product_id']}", $message, 'warning'); } if ($this->review->delete($this->data_review['review_id'])) { ...
Deletes a review
entailment
protected function controlAccessEditReview() { if (!$this->config('review_enabled', 1) || empty($this->uid)) { $this->outputHttpStatus(403); } if (!$this->config('review_editable', 1)) { $this->outputHttpStatus(403); } if (isset($this->data_review['r...
Controls access to the edit review page
entailment
protected function prepareReview(array &$review) { $rating = $this->rating->getByUser($this->data_product['product_id'], $this->uid); $review['rating'] = isset($rating['rating']) ? $rating['rating'] : 0; }
Prepares an array of review data @param array $review
entailment
protected function prepareProductReview(array &$product) { $this->setItemImages($product, 'product', $this->image); $this->setItemThumbProduct($product, $this->image); $this->setItemPriceCalculated($product, $this->product); $this->setItemPriceFormatted($product, $this->price, $this-...
Prepares an array of product data @param array $product
entailment
public function getLoader() { if (null === $this->loader) { $locator = new FileLocator($this->paths); $resolver = new LoaderResolver(array( new YamlFileLoader($locator), new PhpFileLoader($locator), new IniFileLoader($locator), ...
Returns a loader to handle config loading. @return DelegatingLoader The loader
entailment
public function getList(array $options = array()) { $methods = &gplcart_static(gplcart_array_hash(array('payment.methods' => $options))); if (isset($methods)) { return $methods; } $methods = $this->getDefaultList(); $this->hook->attach('payment.methods', $method...
Returns an array of payment methods @param array $options @return array
entailment
public function get($method_id) { $methods = $this->getList(); return empty($methods[$method_id]) ? array() : $methods[$method_id]; }
Returns a payment method @param string $method_id @return array
entailment
public function setAlias(array $data, $alias_model, $entity, $delete_existing = true) { if ((empty($data['form']) && empty($data['alias'])) || empty($data[$entity . '_id'])) { return null; } if ($delete_existing) { $alias_model->delete(array('entity' => $entity, 'ent...
Deletes and/or adds an alias @param array $data @param \gplcart\core\models\Alias $alias_model @param string $entity @param boolean $delete_existing @return mixed
entailment
public function enable($module_id) { try { $result = $this->canEnable($module_id); } catch (Exception $ex) { $result = $ex->getMessage(); } $this->hook->attach("module.enable.before|$module_id", $result, $this); if ($result !== true) { re...
Enables a module @param string $module_id @return boolean|string
entailment
public function disable($module_id) { try { $result = $this->canDisable($module_id); } catch (Exception $ex) { $result = $ex->getMessage(); } $this->hook->attach("module.disable.before|$module_id", $result, $this); if ($result !== true) { ...
Disables a module @param string $module_id @return boolean|string
entailment
public function install($module_id, $status = true) { gplcart_static_clear(); try { $result = $this->canInstall($module_id); } catch (Exception $ex) { $result = $ex->getMessage(); } $this->hook->attach("module.install.before|$module_id", $result, $th...
Install a module @param string $module_id @param boolean $status @return mixed
entailment
public function uninstall($module_id) { try { $result = $this->canUninstall($module_id); } catch (Exception $ex) { $result = $ex->getMessage(); } $this->hook->attach("module.uninstall.before|$module_id", $result, $this); if ($result !== true) { ...
Un-install a module @param string $module_id @return mixed
entailment
public function canEnable($module_id) { if ($this->module->isEnabled($module_id)) { throw new UnexpectedValueException($this->translation->text('Module already installed and enabled')); } if ($this->module->isLocked($module_id)) { throw new UnexpectedValueException($...
Whether a given module can be enabled @param string $module_id @return mixed @throws UnexpectedValueException
entailment
public function canInstall($module_id) { if ($this->module->isInstalled($module_id)) { throw new UnexpectedValueException($this->translation->text('Module already installed')); } if ($this->module->isLocked($module_id)) { throw new UnexpectedValueException($this->tra...
Whether a given module can be installed (and enabled) @param string $module_id @return mixed @throws UnexpectedValueException
entailment
public function canUninstall($module_id) { if ($this->module->isActiveTheme($module_id)) { $error = $this->translation->text('Modules with "theme" type and active status cannot be disabled/uninstalled'); throw new UnexpectedValueException($error); } if ($this->module...
Whether a given module can be un-installed @param string $module_id @return bool @throws UnexpectedValueException
entailment
public function checkRequirements($module_id) { $this->checkModuleId($module_id); $module = $this->module->getInfo($module_id); $this->checkCore($module); $this->checkPhpVersion($module); if ($this->module->isInstaller($module_id)) { $error = $this->translation->...
Checks all requirements for the module @param string $module_id @return bool @throws UnexpectedValueException
entailment
public function checkDependenciesExtensions(array $module) { if (!empty($module['extensions'])) { $missing = array(); foreach ($module['extensions'] as $extension) { if (!extension_loaded($extension)) { $missing[] = $extension; } ...
Check if all required extensions (if any) are loaded @param array $module @return bool @throws UnexpectedValueException
entailment
public function checkPhpVersion(array $module) { if (!empty($module['php'])) { $components = $this->getVersionComponents($module['php']); if (empty($components)) { throw new UnexpectedValueException($this->translation->text('Failed to read PHP version')); ...
Checks PHP version compatibility for the module ID @param array $module @return boolean @throws UnexpectedValueException
entailment
public function checkModuleId($module_id) { if (!$this->module->isValidId($module_id)) { throw new UnexpectedValueException($this->translation->text('Invalid module ID')); } return true; }
Checks a module ID @param string $module_id @return boolean @throws UnexpectedValueException
entailment
public function checkCore(array $module) { if (!isset($module['core'])) { throw new OutOfBoundsException($this->translation->text('Missing core version')); } if (version_compare(gplcart_version(), $module['core']) < 0) { throw new UnexpectedValueException($this->tran...
Checks core version requirements @param array $module @return boolean @throws OutOfBoundsException @throws UnexpectedValueException
entailment
public function checkDependentModules($module_id, array $modules) { unset($modules[$module_id]); $required_by = array(); foreach ($modules as $info) { if (empty($info['dependencies'])) { continue; } foreach (array_keys($info['dependenci...
Checks dependent modules @param string $module_id @param array $modules @return bool @throws UnexpectedValueException
entailment
public function getOverrideMap() { gplcart_static_clear(); $map = array(); foreach ($this->module->getEnabled() as $module) { $directory = GC_DIR_MODULE . "/{$module['id']}/override/classes"; if (!is_readable($directory)) { continue; } ...
Returns an array of class name spaces to be overridden @return array
entailment
protected function checkDependenciesModule($module_id) { $modules = $this->module->getList(); $validated = $this->validateDependencies($modules, true); if (empty($validated[$module_id]['errors'])) { return true; } $messages = array(); foreach ($validated...
Checks module dependencies @param string $module_id @return boolean @throws UnexpectedValueException
entailment
protected function scanOverrideFiles($directory, array &$results = array()) { foreach (new DirectoryIterator($directory) as $file) { if ($file->isFile() && $file->getExtension() === 'php') { $results[] = $file->getFilename(); } elseif ($file->isDir() && !$file->isDot(...
Recursively scans module override files @param string $directory @param array $results @return array
entailment
public function listAccountAddress($user_id) { $this->setUserAccountAddress($user_id); $this->actionAccountAddress(); $this->setTitleListAccountAddress(); $this->setBreadcrumbListAccountAddress(); $this->setData('user', $this->data_user); $this->setData('addresses', ...
Displays the address overview page @param integer $user_id
entailment
protected function getListAccountAddress() { $addresses = $this->address->getTranslatedList($this->data_user['user_id']); return $this->prepareListAccountAddress($addresses); }
Returns an array of addresses @return array
entailment
protected function prepareListAccountAddress(array $addresses) { $prepared = array(); foreach ($addresses as $address_id => $items) { $prepared[$address_id]['items'] = $items; $prepared[$address_id]['locked'] = !$this->address->canDelete($address_id); } retu...
Prepares an array of user addresses @param array $addresses @return array
entailment
protected function actionAccountAddress() { $key = 'delete'; $this->controlToken($key); $address_id = $this->getQuery($key); if (!empty($address_id)) { if ($this->address->delete($address_id)) { $this->redirect('', $this->text('Address has been deleted')...
Handles various actions
entailment
protected function setBreadcrumbListAccountAddress() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('/'), 'text' => $this->text('Shop') ); $breadcrumbs[] = array( 'text' => $this->text('Account'), 'url' => $this...
Sets breadcrumbs on the address overview page
entailment
public static function popBeforeSmtp( $host, $port = false, $tval = false, $username = '', $password = '', $debug_level = 0 ) { $pop = new POP3; return $pop->authorise($host, $port, $tval, $username, $password, $debug_level); }
Simple static wrapper for all-in-one POP before SMTP @param $host @param boolean $port @param boolean $tval @param string $username @param string $password @param integer $debug_level @return boolean
entailment
private function setError($error) { $this->errors[] = $error; if ($this->do_debug >= 1) { echo '<pre>'; foreach ($this->errors as $error) { print_r($error); } echo '</pre>'; } }
Add an error to the internal error store. Also display debug output if it's enabled. @param $error
entailment
private function catchWarning($errno, $errstr, $errfile, $errline) { $this->setError(array( 'error' => "Connecting to the POP3 server raised a PHP warning: ", 'errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline ...
POP3 connection error handler. @param integer $errno @param string $errstr @param string $errfile @param integer $errline @access private
entailment
public function read($length) { if (! $this->resource || ! $this->isReadable()) { return false; } if ($this->eof()) { return ''; } return fread($this->resource, $length); }
Read data from the stream. @param int $length Read up to $length bytes from the object and return them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes. @return string|false Returns the data read from the stream; in the event of an error or inability to read, can return boolean ...
entailment
public function getMetadata($key = null) { if (null === $key) { return stream_get_meta_data($this->resource); } $metadata = stream_get_meta_data($this->resource); if (! array_key_exists($key, $metadata)) { return; } return $metadata[$key]; ...
Retrieve metadata from the underlying stream. @see http://php.net/stream_get_meta_data for a description of the expected output. @return array
entailment
public function route(array $condition) { if (!in_array($condition['operator'], array('=', '!='))) { return false; } $route = $this->route->get(); return $this->compare($route['pattern'], $condition['value'], $condition['operator']); }
Returns true if route condition is met @param array $condition @return boolean
entailment
public function path(array $condition) { if (!in_array($condition['operator'], array('=', '!='))) { return false; } $path = $this->url->path(); $found = false; foreach ((array) $condition['value'] as $pattern) { if (gplcart_path_match($path, $patter...
Returns true if path condition is met @param array $condition @return boolean
entailment
public function add(array $data) { $result = null; $this->hook->attach('file.add.before', $data, $result, $this); if (isset($result)) { return (int) $result; } if (empty($data['mime_type'])) { $data['mime_type'] = mime_content_type(gplcart_file_absol...
Adds a file to the database @param array $data @return integer
entailment
public function delete($condition, $check = true) { $result = null; $this->hook->attach('file.delete.before', $condition, $check, $result, $this); if (isset($result)) { return (bool) $result; } if (!is_array($condition)) { $condition = array('file_id...
Deletes a file from the database @param int|array $condition @param bool $check @return boolean
entailment
public function deleteFromDisk($file) { if (!is_array($file)) { $file = $this->get($file); } $result = null; $this->hook->attach('file.delete.disk.before', $file, $result, $this); if (isset($result)) { return (bool) $result; } if (em...
Deletes a file from disk @param array|int $file @return boolean
entailment
public function deleteAll($file, &$db = 0, &$disk = 0, $check = true) { if (!is_array($file)) { $file = $this->get($file); } if (!isset($file['file_id'])) { return false; } if (!$this->delete($file['file_id'], $check)) { return false; ...
Deletes a file both from database and disk @param int|array $file @param int $db @param int $disk @param bool $check @return bool
entailment
public function canDelete($file_id) { $sql = 'SELECT NOT EXISTS (SELECT file_id FROM product_sku WHERE file_id=:id)'; return (bool) $this->db->fetchColumn($sql, array('id' => (int) $file_id)); }
Whether the file can be deleted @param integer $file_id @return boolean
entailment
public function supportedExtensions($dot = false) { $extensions = array(); foreach ($this->getHandlers() as $handler) { if (!empty($handler['extensions'])) { $extensions += array_merge($extensions, (array) $handler['extensions']); } } $extensi...
Returns an array of all supported file extensions @param boolean $dot @return array
entailment
public function getHandler($name) { $handlers = $this->getHandlers(); if (strpos($name, '.') !== 0) { return isset($handlers[$name]) ? $handlers[$name] : array(); } $extension = ltrim($name, '.'); foreach ($handlers as $handler) { if (empty($handle...
Returns a handler data @param string $name @return array
entailment
protected function validateCastValue($val) { if (isset($this->descriptor()->bareNumber) && $this->descriptor()->bareNumber === false) { return mb_ereg_replace('((^\D*)|(\D*$))', '', $val); } elseif (!is_numeric($val)) { throw $this->getValidationException('value must be numer...
@param mixed $val @return int @throws \frictionlessdata\tableschema\Exceptions\FieldValidationException;
entailment
public function init(Request $request, $postType, $id) { // 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); } ...
Delete a single post
entailment
protected function validateData() { $field = 'data'; if ($this->isExcluded($field)) { return null; } $value = $this->getSubmitted($field); if (!isset($value)) { $this->unsetSubmitted($field); return null; } if (!is_array...
Validates "data" field @return bool|null
entailment
protected function validateMetaTitle() { $field = 'meta_title'; $value = $this->getSubmitted($field); if (!isset($value)) { $this->unsetSubmitted($field); return true; } if (mb_strlen($value) > 60) { $this->setErrorLengthRange($field, $th...
Validates a meta title @return boolean
entailment
protected function validateBool($field) { $value = $this->getSubmitted($field); if (!isset($value)) { $this->unsetSubmitted($field); return null; } $this->setSubmitted($field, (int) filter_var($value, FILTER_VALIDATE_BOOLEAN)); return true; }
Convert different values into boolean @param mixed $field @return bool|null
entailment
protected function validateTranslation() { $translations = $this->getSubmitted('translation'); if (empty($translations)) { return null; } $lengths = array( 'meta_title' => 60, 'meta_description' => 160 ); foreach ($translations a...
Validates category translations @return boolean|null
entailment
protected function validateImages() { $field = 'images'; $images = $this->getSubmitted($field); if (empty($images) || !is_array($images)) { $this->unsetSubmitted($field); return null; } foreach ($images as &$image) { if (isset($image['ti...
Validates / prepares an array of submitted images @return null|bool
entailment
protected function validateUploadImages($entity) { $files = $this->request->file('files'); if (empty($files['name'][0])) { return null; } $directory = $this->config->get("{$entity}_image_dirname", $entity); $results = $this->file_transfer->uploadMultiple($files,...
Validates uploaded images @param string $entity @return bool|null
entailment
protected function validateAlias() { $field = 'alias'; $value = $this->getSubmitted($field); if (empty($value)) { $this->unsetSubmitted($field); return null; } $label = $this->translation->text('Alias'); if (mb_strlen($value) > 255) { ...
Validates an alias @return boolean|null
entailment
protected function validateEmail() { $field = 'email'; if ($this->isExcluded($field)) { return null; } $value = $this->getSubmitted($field); if ($this->isUpdating() && !isset($value)) { $this->unsetSubmitted($field); return null; ...
Validates an E-mail @return boolean
entailment
public function addData(Serializing $event) { if ($event->isSerializer(ForumSerializer::class) && $event->actor->isAdmin()) { $event->attributes['datitisev-dashboard.data'] = [ 'postCount' => Post::where('type', 'comment')->count(), 'discussionCount' => Disc...
Adds settings to admin settings. @param Serializing $event
entailment
public function listReportStatus() { $this->setTitleListReportStatus(); $this->setBreadcrumbListReportStatus(); $this->setData('statuses', $this->getReportStatus()); $this->outputListReportStatus(); }
Displays the status page
entailment
public function getVolume(array $order, array &$cart) { $result = null; $this->hook->attach('order.volume.get.before', $order, $cart, $result, $this); if (isset($result)) { return (float) $result; } $total = 0.0; foreach ($cart['items'] as &$item) { ...
Returns a total volume of all products in the order @param array $order @param array $cart @return float|null
entailment
public function getWeight(array $order, array &$cart) { $result = null; $this->hook->attach('order.weight.get.before', $order, $cart, $result, $this); if (isset($result)) { return (float) $result; } $total = 0.0; foreach ($cart['items'] as &$item) { ...
Returns a total weight of all products in the order @param array $order @param array $cart @return float|null
entailment
protected function sumTotalVolume(&$total, array &$item, array $order) { $product = &$item['product']; if (empty($product['width']) || empty($product['height']) || empty($product['length'])) { return null; } if ($product['size_unit'] !== $order['size_unit']) { ...
Sum volume totals @param float $total @param array $item @param array $order @return null
entailment
protected function sumTotalWeight(&$total, array &$item, array $order) { $product = &$item['product']; if ($product['weight_unit'] !== $order['weight_unit']) { try { $product['weight'] = $this->convertor->convert($product['weight'], $product['weight_unit'], $order['weig...
Sum weight totals @param float $total @param array $item @param array $order @return null
entailment
public function createService(ServiceLocatorInterface $serviceLocator) { $routeCollection = new RouteCollection(); $requestContext = $serviceLocator->get('RouterRequestContext'); $routerOptions = array(); $logger = $serviceLocator->has('logger') ? $serviceLocator->get('Logger') :...
Create and return the router. @param ServiceLocatorInterface $serviceLocator @return \PPI\Framework\Router\Router
entailment
public function getModulesPath() { $paths = $this->locator->getModulesPath(); foreach (array_keys($paths) as $module) { $paths[$module] .= DIRECTORY_SEPARATOR . TemplateReference::MODULE_VIEWS_DIRECTORY; } return $paths; }
Returns an array of paths to modules views dir. @return array An array of paths to each loaded module
entailment
public function listProductClass() { $this->actionListProductClass(); $this->setTitleListProductClass(); $this->setBreadcrumbListProductClass(); $this->setFilterListProductClass(); $this->setPagerListProductClass(); $this->setData('product_classes', $this->getListPro...
Returns the product class overview page
entailment
public function setPagerListProductClass() { $conditions = $this->query_filter; $conditions['count'] = true; $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->product_class->getList($conditions) ); return $this->data_limit = $th...
Set pager on the product class overview page @return array
entailment
protected function getListProductClass() { $conditions = $this->query_filter; $conditions['limit'] = $this->data_limit; return (array) $this->product_class->getList($conditions); }
Returns an array of product classes @return array
entailment
public function editProductClass($product_class_id = null) { $this->setProductClass($product_class_id); $this->setTitleEditProductClass(); $this->setBreadcrumbEditProductClass(); $this->setData('can_delete', $this->canDeleteProductClass()); $this->setData('product_class', $t...
Route callback for the edit product class page @param null|integer $product_class_id
entailment
protected function canDeleteProductClass() { return isset($this->data_product_class['product_class_id']) && $this->access('product_class_delete') && $this->product_class->canDelete($this->data_product_class['product_class_id']); }
Whether a product class can be deleted @return bool
entailment
protected function submitEditProductClass() { if ($this->isPosted('delete') && $this->canDeleteProductClass()) { $this->deleteProductClass(); } else if ($this->isPosted('save') && $this->validateEditProductClass()) { if (isset($this->data_product_class['product_class_id'])) {...
Handles a submitted product class
entailment
protected function validateEditProductClass() { $this->setSubmitted('product_class'); $this->setSubmittedBool('status'); $this->setSubmitted('update', $this->data_product_class); $this->validateComponent('product_class'); return !$this->hasErrors(); }
Validates a products class data @return bool
entailment
protected function deleteProductClass() { $this->controlAccess('product_class_delete'); if ($this->product_class->delete($this->data_product_class['product_class_id'])) { $this->redirect('admin/content/product-class', $this->text('Product class has been deleted'), 'success'); } ...
Deletes a product class
entailment
protected function updateProductClass() { $this->controlAccess('product_class_edit'); if ($this->product_class->update($this->data_product_class['product_class_id'], $this->getSubmitted())) { $this->redirect('admin/content/product-class', $this->text('Product class has been updated'), '...
Updates a product class
entailment
protected function addProductClass() { $this->controlAccess('product_class_add'); if ($this->product_class->add($this->getSubmitted())) { $this->redirect('admin/content/product-class', $this->text('Product class has been added'), 'success'); } $this->redirect('', $this-...
Adds a new product class
entailment
protected function setTitleEditProductClass() { if (isset($this->data_product_class['product_class_id'])) { $title = $this->text('Edit %name', array('%name' => $this->data_product_class['title'])); } else { $title = $this->text('Add product class'); } $this->...
Sets title on the edit product class page
entailment
protected function setBreadcrumbEditProductClass() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'text' => $this->text('Product classes'), ...
Sets breadcrumbs on the edit product class page
entailment
public function get($order_id) { $result = null; $this->hook->attach('order.get.before', $order_id, $result, $this); if (isset($result)) { return $result; } $conditions = array( 'limit' => array(0, 1), 'order_id' => $order_id ); ...
Loads an order from the database @param integer $order_id @return array
entailment
public function add(array $order) { $result = null; $this->hook->attach('order.add.before', $order, $result, $this); if (isset($result)) { return (int) $result; } unset($order['order_id']); // In case the order is cloning $order['created'] = $order['modi...
Adds an order @param array $order @return integer
entailment
public function update($order_id, array $data) { $result = null; $this->hook->attach('order.update.before', $order_id, $data, $result, $this); if (isset($result)) { return (bool) $result; } $data['modified'] = GC_TIME; $this->prepareComponents($data); ...
Updates an order @param integer $order_id @param array $data @return boolean
entailment
public function delete($order_id) { $result = null; $this->hook->attach('order.delete.before', $order_id, $result, $this); if (isset($result)) { return (bool) $result; } $result = (bool) $this->db->delete('orders', array('order_id' => $order_id)); if ($...
Deletes an order @param integer $order_id @return boolean
entailment
public function getStatuses() { $statuses = &gplcart_static('order.statuses'); if (isset($statuses)) { return $statuses; } $statuses = array( 'pending' => $this->translation->text('Pending'), 'canceled' => $this->translation->text('Canceled'), ...
Returns an array of order statuses @return array
entailment
public function getStatusName($id) { $statuses = $this->getStatuses(); return isset($statuses[$id]) ? $statuses[$id] : ''; }
Returns a status name @param string $id @return string
entailment
public function getComponentTypes() { $types = array( 'cart' => $this->translation->text('Cart'), 'payment' => $this->translation->text('Payment'), 'shipping' => $this->translation->text('Shipping') ); $this->hook->attach('order.component.types', $types);...
Returns an array of order component types @return array
entailment
public function getComponentType($name) { $types = $this->getComponentTypes(); return empty($types[$name]) ? '' : $types[$name]; }
Returns a component type name @param string $name @return string
entailment
public function calculate(array &$data) { $result = array(); $this->hook->attach('order.calculate.before', $data, $result, $this); if (!empty($result)) { return (array) $result; } $components = array(); $total = $data['cart']['total']; $this->ca...
Calculates order totals @param array $data @return array
entailment
public function getCompleteMessage(array $order) { $vars = array( '@num' => $order['order_id'], '@status' => $this->getStatusName($order['status']) ); if (is_numeric($order['user_id'])) { $message = $this->translation->text('Thank you for your order! Orde...
Returns the checkout complete message @param array $order @return string
entailment
protected function calculateComponents(&$total, array &$data, array &$components) { foreach (array('shipping', 'payment') as $type) { if (isset($data['order'][$type]) && isset($data[$type . '_methods'][$data['order'][$type]]['price'])) { $price = $data[$type . '_methods'][$data['...
Calculate order components (e.g shipping) using predefined values which can be provided by modules @param int $total @param array $data @param array $components
entailment
protected function calculatePriceRules(&$total, array &$data, array &$components) { $options = array( 'status' => 1, 'store_id' => $data['order']['store_id'] ); $code = null; if (isset($data['order']['data']['pricerule_code'])) { $code = $data['o...
Calculate order price rules @param int $total @param array $data @param array $components
entailment
protected function deleteLinked($order_id) { $this->db->delete('cart', array('order_id' => $order_id)); $this->db->delete('order_log', array('order_id' => $order_id)); $this->db->delete('history', array('entity' => 'order', 'entity_id' => $order_id)); }
Deletes all database records related to the order ID @param int $order_id
entailment
protected function prepareComponents(array &$order) { if (!empty($order['cart']['items'])) { foreach ($order['cart']['items'] as $sku => $item) { $price = isset($item['total']) ? $item['total'] : null; $order['data']['components']['cart']['items'][$sku]['price'] =...
Prepares order components @param array $order
entailment
protected function deleteLinked($page_id) { $this->db->delete('page_translation', array('page_id' => $page_id)); $this->db->delete('file', array('entity' => 'page', 'entity_id' => $page_id)); $this->db->delete('alias', array('entity' => 'page', 'entity_id' => $page_id)); $sql = 'DEL...
Deletes all database records related to the page ID @param int $page_id
entailment
public function getMeta($key) { $postmeta = $this->postmeta; $postmeta = $postmeta->keyBy('meta_key'); if(array_has($postmeta, $key . '.meta_value')){ $returnValue = $postmeta[$key]['meta_value']; return $returnValue; } }
Retrieve the meta value of a certain key
entailment
public function createService(ServiceLocatorInterface $serviceLocator) { if (!$serviceLocator->has('ServiceListener')) { $serviceLocator->setFactory('ServiceListener', 'PPI\Framework\ServiceManager\Factory\ServiceListenerFactory'); } $config = $serviceLocator->get('App...
Creates and returns the module manager. Instantiates the default module listeners, providing them configuration from the "module_listener_options" key of the ApplicationConfig service. Also sets the default config glob path. Module manager is instantiated and provided with an EventManager, to which the default listen...
entailment
public function id(array $condition) { $user_id = $this->user->getId(); return $this->compare($user_id, $condition['value'], $condition['operator']); }
Whether the user ID condition is met @param array $condition @return boolean
entailment
public function roleId(array $condition) { $role_id = $this->user->getRoleId(); return $this->compare($role_id, $condition['value'], $condition['operator']); }
Whether the user role condition is met @param array $condition @return boolean
entailment
public function getPath() { $controller = str_replace('\\', '/', $this->get('controller')); $path = (empty($controller) ? '' : $controller . '/') . $this->get('name') . '.' . $this->get('format') . '.' . $this->get('engine'); return empty($this->parameters['module']) ? self::AP...
Returns the path to the template - as a path when the template is not part of a module - as a resource when the template is part of a module. @return string A path to the template or a resource
entailment
public function getLogicalName() { return sprintf('%s:%s:%s.%s.%s', $this->parameters['module'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']); }
{@inheritdoc}
entailment
public function imageStyle(array &$submitted, array $options = array()) { $this->options = $options; $this->submitted = &$submitted; $this->validateImageStyle(); $this->validateName(); $this->validateBool('status'); $this->validateActionsImageStyle(); $this-...
Performs full image style data validation @param array $submitted @param array $options @return boolean|array
entailment
protected function validateImageStyle() { $id = $this->getUpdatingId(); if ($id === false) { return null; } $data = $this->image_style->get($id); if (empty($data)) { $this->setErrorUnavailable('update', $this->translation->text('Image style')); ...
Validates an image style to be updated @return boolean|null
entailment