sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function validateCreatedReview() { $field = 'created'; $value = $this->getSubmitted($field); if (!isset($value)) { $this->unsetSubmitted($field); return null; } $timestamp = strtotime($value); if (empty($timestamp)) { $...
Validates a created review date @return boolean|null
entailment
protected function validateEmailReview() { $field = 'email'; $value = $this->getSubmitted($field); if (!isset($value)) { $this->unsetSubmitted($field); return null; } $label = $this->translation->text('Email'); if (empty($value)) { ...
Validates a user E-mail @return boolean|null
entailment
public function configureServiceManager(ServiceManager $serviceManager) { foreach ($this->invokables as $name => $class) { $serviceManager->setInvokableClass($name, $class); } foreach ($this->factories as $name => $factoryClass) { $serviceManager->setFactory($name, $...
Configure the provided service manager instance with the configuration in this class. In addition to using each of the internal properties to configure the service manager, also adds an initializer to inject ServiceManagerAware and ServiceLocatorAware classes with the service manager. @param ServiceManager $serviceMa...
entailment
public function build(array $parameters = array()) { if (!isset($this->config['framework'])) { $this->config['framework'] = array(); } // Core parameters set by PPI\Framework\App $parametersBag = new ParameterBag($parameters); $parametersBag->resolve(); $...
@param array $parameters @return $this
entailment
public function executeCron() { $this->controlAccessExecuteCron(); $this->cron->run(); $this->response->outputHtml($this->text('Cron has started')); }
Processes CRON requests
entailment
protected function controlAccessExecuteCron() { if (strcmp($this->getQuery('key', ''), $this->cron->getKey()) !== 0) { $this->response->outputError403(false); } }
Controls access to execute CRON
entailment
public static function create($name, $type, $description = null) { $result = new static(); $result->name = $name; $result->type = $type; $result->description = $description; return $result; }
@param string $name @param string $type @param string $description @return AttributeBuilder
entailment
public function setReferenceTypes(array $referenceTypes) { $this->referenceTypes = []; foreach ($referenceTypes as $referenceType) { $this->addReferenceType($referenceType); } return $this; }
@param \string[] $referenceTypes @return AttributeBuilder
entailment
public function up() { Schema::create('cms_posts', function (Blueprint $table) { $table->bigIncrements('id'); $table->text('post_title')->nullable(); $table->bigInteger('post_author')->nullable(); $table->longText('post_content')->nullable(); $tab...
Run the migrations. @return void
entailment
public function listField() { $this->actionListField(); $this->setTitleListField(); $this->setBreadcrumbListField(); $this->setFilterListField(); $this->setPagerListField(); $this->setData('fields', $this->getListField()); $this->setData('widget_types', $this...
Displays the field overview page
entailment
protected function actionListField() { list($selected, $action) = $this->getPostedAction(); $deleted = 0; foreach ($selected as $field_id) { if ($action === 'delete' && $this->access('field_delete')) { $deleted += (int) $this->field->delete($field_id); ...
Applies an action to the selected fields
entailment
protected function setPagerListField() { $conditions = $this->query_filter; $conditions['count'] = true; $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->field->getList($conditions) ); return $this->data_limit = $this->setPager...
Set pager @return array
entailment
protected function getListField() { $conditions = $this->query_filter; $conditions['limit'] = $this->data_limit; return (array) $this->field->getList($conditions); }
Returns an array of fields @return array
entailment
public function editField($field_id = null) { $this->setField($field_id); $this->setTitleEditField(); $this->setBreadcrumbEditField(); $this->setData('field', $this->data_field); $this->setData('types', $this->field->getTypes()); $this->setData('can_delete', $this->c...
Displays the field edit form @param integer|null $field_id
entailment
protected function submitEditField() { if ($this->isPosted('delete')) { $this->deleteField(); } else if ($this->isPosted('save') && $this->validateEditField()) { if (isset($this->data_field['field_id'])) { $this->updateField(); } else { ...
Handles a submitted field data
entailment
protected function validateEditField() { $this->setSubmitted('field'); $this->setSubmitted('update', $this->data_field); $this->validateComponent('field'); return !$this->hasErrors(); }
Validates an array of submitted field data @return bool
entailment
protected function canDeleteField() { return isset($this->data_field['field_id']) && $this->field->canDelete($this->data_field['field_id']) && $this->access('field_delete'); }
Whether the field can be deleted @return bool
entailment
protected function setField($field_id) { $this->data_field = array(); if (is_numeric($field_id)) { $conditions = array( 'language' => 'und', 'field_id' => $field_id ); $this->data_field = $this->field->get($conditions); ...
Set a field data @param integer $field_id
entailment
protected function deleteField() { $this->controlAccess('field_delete'); if ($this->field->delete($this->data_field['field_id'])) { $this->redirect('admin/content/field', $this->text('Field has been deleted'), 'success'); } $this->redirect('', $this->text('Field has not...
Deletes a field
entailment
protected function updateField() { $this->controlAccess('field_edit'); if ($this->field->update($this->data_field['field_id'], $this->getSubmitted())) { $this->redirect('admin/content/field', $this->text('Field has been updated'), 'success'); } $this->redirect('', $this...
Updates a field
entailment
protected function addField() { $this->controlAccess('field_add'); if ($this->field->add($this->getSubmitted())) { $this->redirect('admin/content/field', $this->text('Field has been added'), 'success'); } $this->redirect('', $this->text('Field has not been added'), 'war...
Adds a new field
entailment
protected function setTitleEditField() { if (isset($this->data_field['field_id'])) { $title = $this->text('Edit %name', array('%name' => $this->data_field['title'])); } else { $title = $this->text('Add field'); } $this->setTitle($title); }
Sets title on the field edit form
entailment
protected function setBreadcrumbEditField() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'url' => $this->url('admin/content/field'), 'tex...
Sets breadcrumbs on the field edit form
entailment
public function listCurrency() { $this->setTitleListCurrency(); $this->setBreadcrumbListCurrency(); $this->setFilterListCurrency(); $this->setPagerListCurrency(); $this->setData('currencies', (array) $this->getListCurrency()); $this->setData('default_currency', $this...
Displays the currency overview page
entailment
protected function setPagerListCurrency() { $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->getListCurrency(true) ); return $this->data_limit = $this->setPager($pager); }
Sets pager @return array
entailment
protected function getListCurrency($count = false) { $currencies = $this->currency->getList(); $allowed = $this->getAllowedFiltersCurrency(); $this->filterList($currencies, $allowed, $this->query_filter); $this->sortList($currencies, $allowed, $this->query_filter, array('modified' =...
Returns an array of sorted currencies @param bool $count @return array|int
entailment
public function editCurrency($code = null) { $this->setCurrency($code); $this->setTitleEditCurrency(); $this->setBreadcrumbEditCurrency(); $this->setData('edit', isset($code)); $this->setData('currency', $this->data_currency); $this->setData('can_delete', $this->canD...
Displays the currency edit form @param string|null $code
entailment
protected function submitEditCurrency() { if ($this->isPosted('delete')) { $this->deleteCurrency(); } else if ($this->isPosted('save') && $this->validateEditCurrency()) { if (isset($this->data_currency['code'])) { $this->updateCurrency(); } else { ...
Handles a submitted currency data
entailment
protected function validateEditCurrency() { $this->setSubmitted('currency'); $this->setSubmittedBool('status'); $this->setSubmittedBool('default'); $this->setSubmitted('update', $this->data_currency); $this->validateComponent('currency'); return !$this->hasErrors();...
Validates a submitted currency data @return boolean
entailment
protected function canDeleteCurrency() { return isset($this->data_currency['code']) && $this->access('currency_delete') && !$this->isPosted() && $this->currency->canDelete($this->data_currency['code']); }
Whether the currency can be deleted @return bool
entailment
protected function setCurrency($code) { $this->data_currency = array(); if (!empty($code)) { $this->data_currency = $this->currency->get($code); if (empty($this->data_currency)) { $this->outputHttpStatus(404); } } }
Set a currency data @param string $code
entailment
protected function deleteCurrency() { $this->controlAccess('currency_delete'); if ($this->currency->delete($this->data_currency['code'])) { $this->redirect('admin/settings/currency', $this->text('Currency has been deleted'), 'success'); } $this->redirect('', $this->text...
Deletes a currency
entailment
protected function updateCurrency() { $this->controlAccess('currency_edit'); if ($this->currency->update($this->data_currency['code'], $this->getSubmitted())) { $this->redirect('admin/settings/currency', $this->text('Currency has been updated'), 'success'); } $this->red...
Updates a currency
entailment
protected function addCurrency() { $this->controlAccess('currency_add'); if ($this->currency->add($this->getSubmitted())) { $this->redirect('admin/settings/currency', $this->text('Currency has been added'), 'success'); } $this->redirect('', $this->text('Currency has not...
Adds a new currency
entailment
protected function setTitleEditCurrency() { if (isset($this->data_currency['code'])) { $title = $this->text('Edit %name', array('%name' => $this->data_currency['name'])); } else { $title = $this->text('Add currency'); } $this->setTitle($title); }
Sets titles on the currency edit page
entailment
protected function setBreadcrumbEditCurrency() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'url' => $this->url('admin/settings/currency'), ...
Sets breadcrumbs on the currency edit page
entailment
public function castRow($row) { if ($this->isLocked) { // schema is locked, no more inferring is needed return parent::castRow($row); } else { // add the row to the inferrer, update the descriptor according to the best inferred fields $this->fieldsInfe...
@param mixed[] $row @return mixed[] @throws Exceptions\FieldValidationException
entailment
protected function validatePost($request, $post, $validationRules) { $validationRules = $this->validateFieldByConditionalLogic($validationRules, $post, $post); // Lets receive the current items from the post type validation array if(array_key_exists('post_name', $validationRules) && !is_array($valid...
Validating the creation and change of a post
entailment
public function listCountry() { $this->actionListCountry(); $this->setTitleListCountry(); $this->setBreadcrumbListCountry(); $this->setFilterListCountry(); $this->setPagerlListCountry(); $this->setData('countries', $this->getListCountry()); $this->outputListC...
Displays the country overview page
entailment
protected function actionListCountry() { list($selected, $action, $value) = $this->getPostedAction(); $updated = $deleted = 0; foreach ($selected as $code) { if ($action === 'status' && $this->access('country_edit')) { $updated += (int) $this->country->update($...
Applies an action to the selected countries
entailment
protected function setPagerlListCountry() { $conditions = $this->query_filter; $conditions['count'] = true; $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->country->getList($conditions) ); return $this->data_limit = $this->set...
Set pager @return array
entailment
protected function getListCountry() { $conditions = $this->query_filter; $conditions['limit'] = $this->data_limit; return (array) $this->country->getList($conditions); }
Returns an array of countries @return array
entailment
public function editCountry($code = null) { $this->setCountry($code); $this->setTitleEditCountry(); $this->setBreadcrumbEditCountry(); $this->setData('code', $code); $this->setData('country', $this->data_country); $this->setData('zones', $this->getZonesCountry()); ...
Displays the country edit form @param string|null $code
entailment
protected function canDeleteCountry() { return isset($this->data_country['code']) && $this->access('country_delete') && $this->country->canDelete($this->data_country['code']); }
Whether the current country can be deleted @return bool
entailment
protected function setCountry($country_code) { $this->data_country = array(); if (!empty($country_code)) { $this->data_country = $this->country->get($country_code); if (empty($this->data_country)) { $this->outputHttpStatus(404); } } }
Set an array of country data @param string $country_code
entailment
protected function submitEditCountry() { if ($this->isPosted('delete')) { $this->deleteCountry(); } else if ($this->isPosted('save') && $this->validateEditCountry()) { if (isset($this->data_country['code'])) { $this->updateCountry(); } else { ...
Saves a submitted country data
entailment
protected function validateEditCountry() { $this->setSubmitted('country'); $this->setSubmittedBool('status'); $this->setSubmitted('update', $this->data_country); $this->validateComponent('country'); return !$this->hasErrors(); }
Validates a submitted country data @return bool
entailment
protected function deleteCountry() { $this->controlAccess('country_delete'); if ($this->country->delete($this->data_country['code'])) { $this->redirect('admin/settings/country', $this->text('Country has been deleted'), 'success'); } $this->redirect('', $this->text('Coun...
Deletes a country
entailment
protected function updateCountry() { $this->controlAccess('country_edit'); if ($this->country->update($this->data_country['code'], $this->getSubmitted())) { $this->redirect('admin/settings/country', $this->text('Country has been updated'), 'success'); } $this->redirect(...
Updates a country
entailment
protected function addCountry() { $this->controlAccess('country_add'); if ($this->country->add($this->getSubmitted())) { $this->redirect('admin/settings/country', $this->text('Country has been added'), 'success'); } $this->redirect('', $this->text('Country has not been ...
Adds a new country
entailment
protected function setTitleEditCountry() { if (isset($this->data_country['name'])) { $title = $this->text('Edit %name', array('%name' => $this->data_country['name'])); } else { $title = $this->text('Add country'); } $this->setTitle($title); }
Sets titles on the country edit page
entailment
protected function setBreadcrumbEditCountry() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'url' => $this->url('admin/settings/country'), ...
Sets breadcrumbs on the country edit page
entailment
public function formatCountry($country_code) { $this->setCountry($country_code); $this->setTitleFormatCountry(); $this->setBreadcrumbFormatCountry(); $this->setData('format', $this->data_country['format']); $this->submitFormatCountry(); $this->outputFormatCountry();...
Displays address format items for the given country @param string $country_code
entailment
protected function updateFormatCountry() { $format = $this->getSubmitted(); foreach ($format as $id => &$item) { $item['status'] = isset($item['status']); $item['required'] = isset($item['required']); if ($id === 'country') { $item['status'] = 1...
Updates a country format
entailment
protected function setBreadcrumbFormatCountry() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'url' => $this->url('admin/settings/country'), ...
Sets breadcrumbs on the country format edit page
entailment
public function createdToAdmin($order) { $store = $this->store->get($order['store_id']); $store_name = $this->store->getTranslation('title', $this->translation->getLangcode(), $store); $options = array('from' => reset($store['data']['email'])); $default = (array) $this->store->getDe...
Sends an email to admin after a customer created an order @param array $order @return array
entailment
public function createdToCustomer($order) { $store = $this->store->get($order['store_id']); $url = $this->store->getUrl($store); $user = $this->user->get($order['user_id']); $store_name = $this->store->getTranslation('title', $this->translation->getLangcode(), $store); $opti...
Sends an email to a logged in customer after his order has been created @param array $order @return array
entailment
public function add(array $product, array $data) { $result = array(); $this->hook->attach('cart.add.product.before', $product, $data, $result, $this); if (!empty($result)) { return (array) $result; } $data += array( 'quantity' => 1, 'user...
Adds the product to the cart @param array $product @param array $data @return array
entailment
public function toWishlist($cart_id) { $result = null; $this->hook->attach('cart.move.wishlist.before', $cart_id, $result, $this); if (isset($result)) { return (array) $result; } $cart = $this->cart->get($cart_id); if (empty($cart) || !$this->cart->dele...
Moves a cart item to a wishlist @param int $cart_id @return array
entailment
public function delete($cart_id) { $result = array(); $this->hook->attach('cart.delete.item.before', $cart_id, $result, $this); if (!empty($result)) { return (array) $result; } $cart = $this->cart->get($cart_id); if (empty($cart) || !$this->cart->delete...
Deletes a cart item @param int $cart_id @return array
entailment
public function login(array $user, array $cart) { $result = array(); $this->hook->attach('cart.login.before', $user, $cart, $result, $this); if (!empty($result)) { return (array) $result; } if (!$this->config->get('cart_login_merge', 0)) { $this->car...
Performs all needed tasks when customer is logging in during checkout @param array $user @param array $cart @return array
entailment
protected function set(array $data, $increment = true) { $options = array( 'order_id' => 0, 'sku' => $data['sku'], 'user_id' => $data['user_id'], 'store_id' => $data['store_id'] ); $list = $this->cart->getList($options); if (empty($li...
Adds/updates a cart item @param array $data @param bool $increment @return integer
entailment
protected function addToWishlist(array $cart) { $data = array( 'user_id' => $cart['user_id'], 'store_id' => $cart['store_id'], 'product_id' => $cart['product_id'] ); return $this->wishlist_action->add($data); }
Adds a product to the wishlist @param array $cart @return array
entailment
protected function getResultDelete(array $cart) { $options = array( 'user_id' => $cart['user_id'], 'store_id' => $cart['store_id'], ); $content = $this->cart->getContent($options); return array( 'redirect' => '', 'severity' => 'succes...
Returns an array of resulting data after a product has been deleted from a cart @param array $cart @return array
entailment
protected function getResultAdded(array $data) { $options = array( 'user_id' => $data['user_id'], 'store_id' => $data['store_id'] ); $vars = array('@url' => $this->url->get('checkout')); $message = $this->translation->text('Product has been added to your cart...
Returns an array of resulting data after a product has been added to a cart @param array $data @return array
entailment
public function delete($trigger_id) { $result = null; $this->hook->attach('trigger.delete.before', $trigger_id, $result, $this); if (isset($result)) { return (bool) $result; } $result = (bool) $this->db->delete('triggers', array('trigger_id' => $trigger_id)); ...
Deletes a trigger @param integer $trigger_id @return boolean
entailment
public function getTriggered(array $data = array(), array $options = array()) { $options += array('status' => 1); $triggers = (array) $this->getList($options); if (empty($triggers)) { return array(); } $triggered = array(); foreach ($triggers as $trigger...
Returns an array of triggered IDs for the given context @param array $data @param array $options @return array
entailment
protected function prepareList(array $list) { foreach ($list as &$item) { if (!empty($item['data']['conditions'])) { gplcart_array_sort($item['data']['conditions']); } } return $list; }
Prepare an array of triggers @param array $list @return array
entailment
protected function submitWishlist($wishlist_action_model) { $this->setSubmitted('product'); $this->filterSubmitted(array('product_id')); if ($this->isPosted('remove_from_wishlist')) { $this->deleteFromWishlist($wishlist_action_model); } else if ($this->isPosted('add_to_w...
Adds/removes a product from the wishlist @param \gplcart\core\models\WishlistAction $wishlist_action_model
entailment
protected function validateAddToWishlist() { $this->setSubmitted('user_id', $this->getCartUid()); $this->setSubmitted('store_id', $this->getStoreId()); $this->validateComponent('wishlist'); }
Validates adding a submitted product to the wishlist
entailment
public function addToWishlist($wishlist_action_model) { $errors = $this->error(); if (empty($errors)) { $result = $wishlist_action_model->add($this->getSubmitted()); } else { $result = array( 'redirect' => '', 'severity' => 'warning', ...
Add a product to the wishlist @param \gplcart\core\models\WishlistAction $wishlist_action_model
entailment
public function deleteFromWishlist($wishlist_action_model) { $product = array( 'user_id' => $this->getCartUid(), 'store_id' => $this->getStoreId(), 'product_id' => $this->getSubmitted('product_id') ); $result = $wishlist_action_model->delete($product); ...
Deletes a submitted product from the wishlist @param \gplcart\core\models\WishlistAction $wishlist_action_model
entailment
public function boot() { // Register migrations only if its laravel 5.3 or heigher $laravel = app(); $version = $laravel::VERSION; $version = (float) $version; if($version >= 5.3){ $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); } // Register translations $t...
Bootstrap the application services. @return void
entailment
public function listReview() { $this->actionListReview(); $this->setTitleListReview(); $this->setBreadcrumbListReview(); $this->setFilterListReview(); $this->setPagerListReview(); $this->setData('reviews', $this->getListReview()); $this->outputListReview(); ...
Displays the reviews overview page
entailment
protected function setPagerListReview() { $conditions = $this->query_filter; $conditions['count'] = true; $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->review->getList($conditions) ); return $this->data_limit = $this->setPag...
Sets pager @return array
entailment
protected function getListReview() { $conditions = $this->query_filter; $conditions['limit'] = $this->data_limit; return (array) $this->review->getList($conditions); }
Returns an array of reviews @return array
entailment
public function editReview($review_id = null) { $this->setReview($review_id); $this->setTitleEditReview(); $this->setBreadcrumbEditReview(); $this->setData('review', $this->data_review); $this->submitEditReview(); $this->setDataUserEditReview(); $this->setDa...
Displays the review edit form @param integer|null $review_id
entailment
protected function setReview($review_id) { $this->data_review = array(); if (is_numeric($review_id)) { $this->data_review = $this->review->get($review_id); if (empty($this->data_review)) { $this->outputHttpStatus(404); } } }
Set a review data @param integer $review_id
entailment
protected function submitEditReview() { if ($this->isPosted('delete')) { $this->deleteReview(); } else if ($this->isPosted('save') && $this->validateEditReview()) { if (isset($this->data_review['review_id'])) { $this->updateReview(); } else { ...
Handles a submitted review
entailment
protected function validateEditReview() { $this->setSubmitted('review'); $this->setSubmittedBool('status'); $this->setSubmitted('update', $this->data_review); $this->validateComponent('review'); return !$this->hasErrors(); }
Validates a submitted review @return bool
entailment
protected function deleteReview() { $this->controlAccess('review_delete'); if ($this->review->delete($this->data_review['review_id'])) { $this->redirect('admin/content/review', $this->text('Review has been deleted'), 'success'); } $this->redirect('', $this->text('Review...
Deletes a review
entailment
protected function updateReview() { $this->controlAccess('review_edit'); if ($this->review->update($this->data_review['review_id'], $this->getSubmitted())) { $this->redirect('admin/content/review', $this->text('Review has been updated'), 'success'); } $this->redirect(''...
Updates a review
entailment
protected function addReview() { $this->controlAccess('review_add'); if ($this->review->add($this->getSubmitted())) { $this->redirect('admin/content/review', $this->text('Review has been added'), 'success'); } $this->redirect('', $this->text('Review has not been added')...
Adds a new review
entailment
protected function setDataUserEditReview() { $user = $this->user->get($this->getData('review.user_id')); if (isset($user['email'])) { $this->setData('review.email', $user['email']); } }
Set user template data
entailment
protected function setDataProductEditReview() { $product_id = $this->getData('review.product_id'); $products = array(); if (!empty($product_id)) { $product = $this->product->get($product_id); $options = array( 'entity' => 'product', ...
Set product template data
entailment
protected function setTitleEditReview() { if (isset($this->data_review['review_id'])) { $title = $this->text('Edit %name', array('%name' => $this->text('Review'))); } else { $title = $this->text('Add review'); } $this->setTitle($title); }
Sets title on the edit review page
entailment
protected function setBreadcrumbEditReview() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'text' => $this->text('Reviews'), 'url' => $thi...
Sets breadcrumbs on the edit review page
entailment
public function zoneId(array $condition, array $data, $key) { if (isset($data['data']['order'][$key])) { return $this->checkZoneIdByAddressId($condition, $data, $key); } return $this->checkZoneIdByAddressData($condition, $data); }
Whether the zone ID condition is met @param array $condition @param array $data @param string $key @return boolean
entailment
public function countryCode(array $condition, array $data, $key) { // Check form fields if (!empty($data['data']['address']['country'])) { $country = $data['data']['address']['country']; return $this->compare($country, $condition['value'], $condition['operator']); } ...
Whether the country condition is met @param array $condition @param array $data @param string $key @return boolean
entailment
public function stateId(array $condition, array $data, $key) { // Check form fields if (isset($data['data']['address']['state_id'])) { $state_id = $data['data']['address']['state_id']; return $this->compare($state_id, $condition['value'], $condition['operator']); } ...
Whether the state ID condition is met @param array $condition @param array $data @param string $key @return boolean
entailment
protected function checkZoneIdByAddressId($condition, $data, $key) { $address = $this->address->get($data['data']['order'][$key]); if (empty($address)) { return false; } $fields = array('country_zone_id', 'state_zone_id', 'city_zone_id'); $ids = array(); ...
Whether the state ID condition is met using an existing address @param array $condition @param array $data @param string $key @return boolean
entailment
protected function checkZoneIdByAddressData($condition, $data) { if (empty($data['data']['order']['address'])) { return false; } $ids = $this->getAddressZoneId($data['data']['order']['address']); return $this->compare($ids, $condition['value'], $condition['operator']); ...
Whether the state ID condition is met using form fields @param array $condition @param array $data @return boolean
entailment
protected function getAddressZoneId(array $address) { $result = array(); foreach (array('state_id', 'city_id', 'country') as $field) { if (empty($address[$field])) { continue; } if ($field === 'city_id') { $data = $this->city->ge...
Returns an array of zone IDs from address components @param array $address @return array
entailment
public function setRule($rule, $replacement) { if (is_array($rule)) { $this->rules = $rule; return $this; } $this->rules[$rule] = $replacement; return $this; }
Adds a rule @param string|array $rule A single RegExp pattern or array of rules @param string $replacement A replacement HTML string or callable method @return $this
entailment
public function render($text) { $text = trim(str_replace(array("\r\n", "\r"), "\n", $text), "\n"); foreach ($this->rules as $regex => $replacement) { if (is_callable($replacement)) { $text = preg_replace_callback($regex, $replacement, $text); } else { ...
Renders Markdown text into HTML @param string $text @return string
entailment
protected static function p(array $matches) { $line = $matches[1]; $trimmed = trim($line); if (preg_match('/^<\/?(ul|ol|li|h|p|bl)/', $trimmed)) { return "\n$line\n"; } return sprintf("\n<p>%s</p>\n", $trimmed); }
Renders "P" tag @param array $matches @return string
entailment
protected static function h(array $matches) { $level = strlen($matches[1]); return sprintf('<h%d>%s</h%d>', $level, trim($matches[2]), $level); }
Renders "H" tag @param array $matches @return string
entailment
public static function deserializeObject(array $data) { /** @var ResourceType $result */ $result = self::deserializeCommonAttributes($data); $result->name = $data['name']; $result->description = $data['description']; $result->endpoint = $data['endpoint']; $result->sch...
@param array $data @return ResourceType
entailment
public function getThumb(array $data, array $options) { $options += array( 'placeholder' => true, 'imagestyle' => $this->config->get('image_style', 3)); if (empty($options['entity_id'])) { return empty($options['placeholder']) ? '' : $this->getPlaceholder($option...
Returns a string containing a thumbnail image URL @param array $data @param array $options @return string
entailment
public function delete($file_id) { if (empty($file_id)) { return false; } $deleted = $count = 0; foreach ((array) $this->file->getList(array('file_id' => $file_id)) as $file) { $deleted += (int) $this->file->delete($file['file_id']); $count++; ...
Delete images by file ID(s) @param int|array $file_id @return bool
entailment