sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
protected function deleteCountryState()
{
$this->controlAccess('state_delete');
if ($this->state->delete($this->data_state['state_id'])) {
$url = "admin/settings/states/{$this->data_country['code']}";
$this->redirect($url, $this->text('Country state has been deleted'), 'success');
}
$this->redirect('', $this->text('Country state has not been deleted'), 'warning');
} | Deletes a country state | entailment |
protected function updateCountryState()
{
$this->controlAccess('state_edit');
if ($this->state->update($this->data_state['state_id'], $this->getSubmitted())) {
$url = "admin/settings/states/{$this->data_country['code']}";
$this->redirect($url, $this->text('Country state has been updated'), 'success');
}
$this->redirect('', $this->text('Country state has not been updated'), 'warning');
} | Updates a country state | entailment |
protected function addCountryState()
{
$this->controlAccess('state_add');
if ($this->state->add($this->getSubmitted())) {
$url = "admin/settings/states/{$this->data_country['code']}";
$this->redirect($url, $this->text('Country state has been added'), 'success');
}
$this->redirect('', $this->text('Country state has not been added'), 'warning');
} | Adds a new country state | entailment |
protected function setTitleEditCountryState()
{
if (isset($this->data_state['state_id'])) {
$title = $this->text('Edit %name', array('%name' => $this->data_state['name']));
} else {
$title = $this->text('Add country state for %name', array('%name' => $this->data_country['name']));
}
$this->setTitle($title);
} | Sets titles on the edit country state page | entailment |
protected function setBreadcrumbEditCountryState()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'url' => $this->url('admin/settings/country'),
'text' => $this->text('Countries')
);
$breadcrumbs[] = array(
'url' => $this->url("admin/settings/states/{$this->data_country['code']}"),
'text' => $this->text('Country states of %name', array('%name' => $this->data_country['code']))
);
$this->setBreadcrumbs($breadcrumbs);
} | Set breadcrumbs on the edit country state page | entailment |
public function productBundle(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateProductProductBundle();
$this->validateItemsProductBundle();
return $this->getResult();
} | Performs validation of submitted product bundle data
@param array $submitted
@param array $options
@return array|boolean | entailment |
protected function validateItemsProductBundle()
{
$field = 'bundle';
$value = $this->getSubmitted($field);
if (empty($value)) {
return null;
}
if (!is_array($value)) {
$this->setErrorInvalid($field, $this->translation->text('Product bundle'));
return false;
}
$main_product = $this->getSubmitted('product');
$loaded = array();
foreach ($value as $product_id) {
if (isset($loaded[$product_id])) {
$this->setError($field, $this->translation->text('All bundled products must be unique'));
return false;
}
$product = $this->product->get($product_id);
$loaded[$product_id] = $product;
if (empty($product['status'])) {
$this->setError($field, $this->translation->text('Some of bundled products are unavailable'));
return false;
}
if ($main_product['product_id'] == $product['product_id']) {
$this->setError($field, $this->translation->text('Bundled products cannot be the same as the main product'));
return false;
}
if ($main_product['store_id'] != $product['store_id']) {
$this->setError($field, $this->translation->text('All bundled products must belong to the same store'));
return false;
}
}
$this->setSubmitted('products', $loaded);
return true;
} | Validates bundled products
@return boolean|null | entailment |
public function compare(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateProductCompare();
return $this->getResult();
} | Performs full product comparison data validation
@param array $submitted
@param array $options
@return boolean|array | entailment |
public function get($schemaId)
{
$class = $this->getSchemaClass();
$data = static::$schemas[$schemaId];
/** @var Schema $schema */
$schema = call_user_func([$class, 'deserializeObject'], $data);
$schema->getMeta()->setLocation($this->schemasEndpointUrl.$schemaId);
return $schema;
} | @param string $schemaId
@return \Tmilos\ScimSchema\Model\v1\Schema|\Tmilos\ScimSchema\Model\v2\Schema|Schema | entailment |
public function initAuth()
{
if ($this->_verified)
return true;
$output = $this->postRequest(
'identification/bankid/mobile',
[
'useEasyLogin' => false,
'generateEasyLoginId' => false,
'userId' => $this->_username,
]);
if ($output->status != 'USER_SIGN')
throw new Exception('Unable to use Mobile BankID. Check if the user have enabled Mobile BankID.', 10);
$this->saveSession();
return true;
} | Initiate Mobile BankID authentication
Sends verification request to the users Mobile BankID app.
@return bool
@throws Exception | entailment |
public function verify()
{
if ($this->_verified)
return true;
$output = $this->getRequest('identification/bankid/mobile/verify');
if (empty($output->status))
throw new Exception('Mobile BankID cannot be verified. Maybe a session timeout.', 11);
$this->_verified = ($output->status == 'COMPLETE');
$this->saveSession();
return $this->_verified;
} | Check Mobile BankID verification
See if the user have confirmed the authentication verification request.
@return bool True if verified. False to check later (eg. 5 seconds) for user verification.
@throws Exception | entailment |
public function zone(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateZone();
$this->validateBool('status');
$this->validateTitle();
$this->unsetSubmitted('update');
return $this->getResult();
} | Performs full zone data validation
@param array $submitted
@param array $options
@return array|boolean | entailment |
protected function validateZone()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->zone->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Zone'));
return false;
}
$this->setUpdating($data);
return true;
} | Validates a zone to be updated
@return boolean|null | entailment |
public function listProduct()
{
$this->actionListProduct();
$this->setTitleListProduct();
$this->setBreadcrumbListProduct();
$this->setFilterListProduct();
$this->setPagerListProduct();
$this->setData('products', $this->getListProduct());
$this->setData('currencies', $this->currency->getList(array('enabled' => true)));
$this->outputListProduct();
} | Displays the product overview page | entailment |
protected function setPagerListProduct()
{
$conditions = $this->query_filter;
$conditions['count'] = true;
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->product->getList($conditions)
);
return $this->data_limit = $this->setPager($pager);
} | Set pager
@return array | entailment |
protected function actionListProduct()
{
list($selected, $action, $value) = $this->getPostedAction();
$deleted = $updated = 0;
foreach ($selected as $id) {
if ($action === 'status' && $this->access('product_edit')) {
$updated += (int) $this->product->update($id, array('status' => $value));
}
if ($action === 'delete' && $this->access('product_delete')) {
$deleted += (int) $this->product->delete($id);
}
}
if ($updated > 0) {
$message = $this->text('Updated %num item(s)', array('%num' => $updated));
$this->setMessage($message, 'success');
}
if ($deleted > 0) {
$message = $this->text('Deleted %num item(s)', array('%num' => $deleted));
$this->setMessage($message, 'success');
}
} | Applies an action to the selected products | entailment |
protected function getListProduct()
{
$conditions = $this->query_filter;
$conditions['limit'] = $this->data_limit;
$list = (array) $this->product->getList($conditions);
$this->prepareListProduct($list);
return $list;
} | Returns an array of products
@return array | entailment |
protected function prepareListProduct(array &$list)
{
foreach ($list as &$item) {
$this->setItemPriceFormatted($item, $this->price);
$this->setItemUrlEntity($item, $this->store, 'product');
}
} | Prepare an array of products
@param array $list | entailment |
public function editProduct($product_id = null)
{
$this->setProduct($product_id);
$this->setTitleEditProduct();
$this->setBreadcrumbEditProduct();
$this->setData('product', $this->data_product);
$this->setData('size_units', $this->convertor->getUnitNames('size'));
$this->setData('weight_units', $this->convertor->getUnitNames('weight'));
$this->setData('default_currency', $this->currency->getDefault());
$this->setData('subtract_default', $this->config->get('product_subtract', 0));
$this->setData('classes', $this->product_class->getList(array('status' => 1)));
$this->setData('languages', $this->language->getList(array('enabled' => true)));
$this->submitEditProduct();
$this->setDataFieldsEditProduct();
$this->setDataAuthorEditProduct();
$this->setDataRelatedEditProduct();
$this->setDataCategoriesEditProduct();
$this->setDataImagesEditProduct();
$this->setJsEditProduct();
$this->outputEditProduct();
} | Displays the product edit form
@param integer|null $product_id | entailment |
protected function getListCategoryProduct($store_id)
{
$types = $this->category_group->getTypes();
$categories = array();
foreach (array_keys($types) as $type) {
$op = array(
'type' => $type,
'store_id' => $store_id
);
$data = $this->getCategoryOptionsByStore($this->category, $this->category_group, $op);
$categories[$type] = reset($data);
}
return $categories;
} | Returns an array of categories keyed by a type
@param integer $store_id
@return array | entailment |
protected function setProduct($product_id)
{
$this->data_product = array();
if (is_numeric($product_id)) {
$conditions = array(
'language' => 'und',
'product_id' => $product_id
);
$this->data_product = $this->product->get($conditions);
if (empty($this->data_product)) {
$this->outputHttpStatus(404);
}
$this->prepareProduct($this->data_product);
}
} | Set a product data
@param integer $product_id | entailment |
protected function prepareProduct(array &$product)
{
$options = array(
'store_id' => $product['store_id'],
'product_id' => $product['product_id']
);
$product['related'] = $this->product->getRelated($options);
$product['price'] = $this->price->decimal($product['price'], $product['currency']);
$this->setSkuCombinationProduct($product);
$this->setItemAlias($product, 'product', $this->alias);
$this->setItemImages($product, 'product', $this->image);
$this->setItemTranslation($product, 'product', $this->translation_entity);
if (!empty($product['images'])) {
foreach ($product['images'] as &$file) {
$this->setItemTranslation($file, 'file', $this->translation_entity);
}
}
} | Prepare an array of product data
@param array $product | entailment |
protected function setSkuCombinationProduct(array &$product)
{
if (!empty($product['combination'])) {
foreach ($product['combination'] as &$combination) {
$combination['path'] = $combination['thumb'] = '';
if (!empty($product['images'][$combination['file_id']])) {
$combination['path'] = $product['images'][$combination['file_id']]['path'];
$this->setItemThumb($combination, $this->image);
}
$combination['price'] = $this->price->decimal($combination['price'], $product['currency']);
}
}
} | Sets product SKU combinations data
@param array $product | entailment |
protected function submitEditProduct()
{
if ($this->isPosted('delete')) {
$this->deleteProduct();
} else if ($this->isPosted('save') && $this->validateEditProduct()) {
$this->deleteImagesProduct();
if (isset($this->data_product['product_id'])) {
$this->updateProduct();
} else {
$this->addProduct();
}
}
} | Handles a submitted product | entailment |
protected function deleteImagesProduct()
{
$this->controlAccess('product_edit');
$file_ids = $this->getPosted('delete_images', array(), true, 'array');
return $this->image->delete($file_ids);
} | Delete product images
@return boolean | entailment |
protected function deleteProduct()
{
$this->controlAccess('product_delete');
if ($this->product->delete($this->data_product['product_id'])) {
$this->redirect('admin/content/product', $this->text('Product has been deleted'), 'success');
}
$this->redirect('', $this->text('Product has not been deleted'), 'warning');
} | Deletes a product | entailment |
protected function validateEditProduct()
{
$this->setSubmitted('product', null, false);
$this->setSubmittedBool('status');
$this->setSubmittedBool('subtract');
$this->setSubmitted('form', true);
$this->setSubmitted('update', $this->data_product);
if (isset($this->data_product['product_id'])) {
$this->setSubmitted('user_id', $this->data_product['user_id']);
$this->setSubmitted('created', $this->data_product['created']);
$this->setSubmitted('modified', $this->data_product['modified']);
$this->setSubmitted('currency', $this->data_product['currency']);
$this->setSubmitted('product_id', $this->data_product['product_id']);
} else {
$this->setSubmitted('user_id', $this->uid);
$this->setSubmitted('currency', $this->currency->getDefault());
}
$this->validateComponent('product');
return !$this->hasErrors();
} | Validates an array of submitted product data
@return bool | entailment |
protected function updateProduct()
{
$this->controlAccess('product_edit');
if ($this->product->update($this->data_product['product_id'], $this->getSubmitted())) {
$this->redirect('admin/content/product', $this->text('Product has been updated'), 'success');
}
$this->redirect('', $this->text('Product has not been updated'), 'warning');
} | Updates a product | entailment |
protected function addProduct()
{
$this->controlAccess('product_add');
if ($this->product->add($this->getSubmitted())) {
$this->redirect('admin/content/product', $this->text('Product has been added'), 'success');
}
$this->redirect('', $this->text('Product has not been added'), 'warning');
} | Adds a new product | entailment |
protected function setDataAuthorEditProduct()
{
$user_id = $this->getData('product.user_id');
if (!empty($user_id)) {
$user = $this->user->get($user_id);
$this->setData('product.author', $user['email']);
}
} | Sets the product author data | entailment |
protected function setDataFieldsEditProduct()
{
$output_field_form = false;
$get_product_class_id = $this->getQuery('product_class_id');
$product_class_id = $this->getData('product.product_class_id', 0);
if (isset($get_product_class_id)) {
$output_field_form = true;
$product_class_id = (int) $get_product_class_id;
}
$data = array(
'product' => $this->getData('product'),
'fields' => $this->product_class->getFields($product_class_id)
);
$options = $this->render('content/product/options', $data);
$attributes = $this->render('content/product/attributes', $data);
$this->setData('option_form', $options);
$this->setData('attribute_form', $attributes);
if ($output_field_form) {
$this->response->outputHtml($attributes . $options);
}
} | Sets attributes/options product data | entailment |
protected function setDataRelatedEditProduct()
{
$product_ids = $this->getData('product.related');
$products = array();
if (!empty($product_ids)) {
$products = (array) $this->product->getList(array('product_id' => $product_ids));
}
$options = array(
'entity' => 'product',
'entity_id' => $product_ids,
'template_item' => 'backend|content/product/suggestion'
);
foreach ($products as &$product) {
$this->setItemThumb($product, $this->image, $options);
$this->setItemPriceFormatted($product, $this->price);
$this->setItemRendered($product, array('item' => $product), $options);
}
$widget = array(
'multiple' => true,
'name' => 'product[related]',
'products' => $products,
'error' => $this->error('related')
);
$this->setData('product_picker', $this->getWidgetProductPicker($widget));
} | Sets related products | entailment |
protected function setTitleEditProduct()
{
if (isset($this->data_product['product_id'])) {
$title = $this->text('Edit %name', array('%name' => $this->data_product['title']));
} else {
$title = $this->text('Add product');
}
$this->setTitle($title);
} | Sets titles on the product edit form | entailment |
protected function setBreadcrumbEditProduct()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'text' => $this->text('Products'),
'url' => $this->url('admin/content/product')
);
$this->setBreadcrumbs($breadcrumbs);
} | Sets breadcrumbs on the product edit page | entailment |
public function product(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateProduct();
$this->validateSubtractProduct();
$this->validateBool('status');
$this->validateCurrencyProduct();
$this->validateCategoryProduct();
$this->validateUnitProduct();
$this->validatePriceProduct();
$this->validateStockProduct();
$this->validateTitle();
$this->validateDescription();
$this->validateMetaTitle();
$this->validateMetaDescription();
$this->validateTranslation();
$this->validateImages();
$this->validateStoreId(false);
$this->validateUserId(false);
$this->validateDimensionProduct();
$this->validateRelatedProduct();
$this->validateClassProduct();
$this->validateSkuProduct();
$this->validateAttributeProduct();
$this->validateCombinationProduct();
$this->validateAlias();
$this->validateUploadImages('product');
$this->unsetSubmitted('update');
return $this->getResult();
} | Performs full product data validation
@param array $submitted
@param array $options
@return array|boolean | entailment |
protected function validateProduct()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->product->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Product'));
return false;
}
$this->setUpdating($data);
return true;
} | Validates a product data
@return boolean|null | entailment |
protected function validateSubtractProduct()
{
$field = 'subtract';
$value = $this->getSubmitted($field);
if (isset($value)) {
$this->setSubmitted($field, filter_var($value, FILTER_VALIDATE_BOOLEAN));
}
return true;
} | Validates "Subtract" bool value
@return boolean | entailment |
protected function validateCategoryProduct()
{
$fields = array(
'category_id' => $this->translation->text('Category'),
'brand_category_id' => $this->translation->text('Brand'),
);
$errors = 0;
foreach ($fields as $field => $label) {
$value = $this->getSubmitted($field);
if (!isset($value)) {
continue;
}
if (!is_numeric($value)) {
$errors++;
$this->setErrorNumeric($field, $label);
continue;
}
if (empty($value)) {
continue;
}
$category = $this->category->get($value);
if (empty($category['category_id'])) {
$errors++;
$this->setErrorUnavailable($field, $label);
}
}
return empty($errors);
} | Validates product categories
@return boolean | entailment |
protected function validateUnitProduct()
{
$allowed = array(
'size_unit' => $this->convertor->getUnitNames('size'),
'weight_unit' => $this->convertor->getUnitNames('weight')
);
$fields = array(
'size_unit' => $this->translation->text('Size unit'),
'weight_unit' => $this->translation->text('Weight unit')
);
$errors = 0;
foreach ($fields as $field => $label) {
$value = $this->getSubmitted($field);
if (isset($value) && !isset($allowed[$field][$value])) {
$errors++;
$this->setErrorUnavailable($field, $label);
}
}
return empty($errors);
} | Validates measurement units
@return boolean | entailment |
protected function validateDimensionProduct()
{
$fields = array(
'width' => $this->translation->text('Width'),
'height' => $this->translation->text('Height'),
'length' => $this->translation->text('Length'),
'weight' => $this->translation->text('Weight')
);
$errors = 0;
foreach ($fields as $field => $label) {
$value = $this->getSubmitted($field);
if (!isset($value)) {
continue;
}
if (!is_numeric($value)) {
$errors++;
$this->setErrorNumeric($field, $label);
}
if (strlen($value) > 10) {
$errors++;
$this->setErrorLengthRange($field, $label, 0, 10);
}
}
return empty($errors);
} | Validates product dimensions
@return boolean | entailment |
protected function validateRelatedProduct()
{
$field = 'related';
if ($this->isExcluded($field) || $this->isError('store_id')) {
return null;
}
$value = $this->getSubmitted($field);
if (empty($value)) {
$this->setSubmitted($field, array());
return null;
}
$store_id = $this->getSubmitted('store_id');
$product_ids = array();
foreach (array_unique($value) as $product_id) {
$product = $this->product->get($product_id);
if (empty($product['store_id'])) {
$this->setError($field, $this->translation->text('Some of related products are invalid'));
return false;
}
if ($product['store_id'] != $store_id) {
$this->setError($field, $this->translation->text('All related product must belong to the same store'));
return false;
}
$product_ids[$product['product_id']] = $product['product_id'];
}
$updating = $this->getUpdating();
if (isset($updating['product_id'])) {
// Exclude the current product from the related products
unset($product_ids[$updating['product_id']]);
}
$this->setSubmitted('related', $product_ids);
return true;
} | Validates related products
@return boolean|null | entailment |
protected function validateSkuProduct()
{
$field = 'sku';
if ($this->isExcluded($field) || $this->isError()) {
return null;
}
$value = $this->getSubmitted($field);
$label = $this->translation->text('SKU');
if ($this->isUpdating() && empty($value)) {
$data = $this->getSubmitted();
$value = $this->product->generateSku($data);
$this->setSubmitted('sku', $value);
}
if (isset($value) && mb_strlen($value) > 255) {
$this->setErrorLengthRange($field, $label, 0, 255);
return false;
}
if (!empty($value)) {
$this->processed_skus[$value] = true;
}
$updating = $this->getUpdating();
if (isset($updating['sku']) && $updating['sku'] === $value) {
return true;
}
$product_id = null;
if (isset($updating['product_id'])) {
$product_id = $updating['product_id'];
}
$store_id = $this->getSubmitted('store_id');
if (isset($updating['store_id'])) {
$store_id = $updating['store_id'];
}
$existing = $this->sku->get(array('sku' => $value, 'store_id' => $store_id));
if (isset($product_id) && isset($existing['product_id']) && $existing['product_id'] == $product_id) {
return true;
}
if (!empty($existing)) {
$this->setErrorExists($field, $label);
return false;
}
return true;
} | Validates a product SKU
@return boolean|null | entailment |
protected function validateClassProduct()
{
$field = 'product_class_id';
$value = $this->getSubmitted($field);
if (empty($value)) {
return null;
}
$label = $this->translation->text('Product class');
if (!is_numeric($value)) {
$this->setErrorNumeric($field, $label);
return false;
}
$product_class = $this->product_class->get($value);
if (empty($product_class)) {
$this->setErrorUnavailable($field, $label);
return false;
}
$fields = $this->product_class->getFields($value);
$this->setSubmitted('product_fields', $fields);
return true;
} | Validates a product class
@return boolean|null | entailment |
protected function validateAttributeProduct()
{
$fields = $this->getSubmitted('product_fields.attribute');
if (empty($fields)) {
return null;
}
$attributes = $this->getSubmitted('field.attribute');
$errors = 0;
foreach ($fields as $field_id => $field) {
if (!empty($field['required']) && empty($attributes[$field_id])) {
$this->setErrorRequired("attribute.$field_id", $field['title']);
$errors++;
}
}
return empty($errors);
} | Validates an array of product attributes
@return boolean|null | entailment |
protected function validateCombinationProduct()
{
$combinations = $this->getSubmitted('combination');
if (empty($combinations)) {
return null;
}
$index = 1;
foreach ($combinations as &$combination) {
$combination['status'] = !empty($combination['status']);
$this->validateCombinationOptionsProduct($index, $combination);
if ($this->isError("combination.$index")) {
continue;
}
if (empty($combination['fields'])) {
unset($combinations[$index]);
continue;
}
$combination_id = $this->sku->getCombinationId($combination['fields']);
if (isset($this->processed_combinations[$combination_id])) {
$error = $this->translation->text('Combination already exists');
$this->setError("combination.$index.exists", $error);
}
$this->validateCombinationSkuProduct($index, $combination);
$this->validateCombinationPriceProduct($index, $combination);
$this->validateCombinationStockProduct($index, $combination);
foreach ($combination['fields'] as $field_value_id) {
if (!isset($this->stock_amount[$field_value_id])) {
$this->stock_amount[$field_value_id] = (int) $combination['stock'];
}
}
$this->processed_combinations[$combination_id] = true;
$index++;
}
if ($this->isError()) {
return false;
}
$this->setSubmitted('combination', $combinations);
$this->setSubmitted('stock', array_sum($this->stock_amount));
return true;
} | Validates an array of product combinations
@return boolean|null | entailment |
protected function validateCombinationOptionsProduct($index, &$combination)
{
$options = $this->getSubmitted('product_fields.option');
if (empty($options)) {
return null;
}
$errors = 0;
foreach ($options as $field_id => $field) {
if (!empty($field['required']) && !isset($combination['fields'][$field_id])) {
$this->setErrorRequired("combination.$index.fields.$field_id", $field['title']);
$errors++;
}
}
return empty($errors);
} | Validates option combination fields
@param integer $index
@param array $combination
@return boolean|null | entailment |
protected function validateCombinationSkuProduct($index, &$combination)
{
if (!isset($combination['sku'])) {
return null;
}
if ($combination['sku'] === '') {
return true;
}
$updating = $this->getUpdating();
$product_id = null;
if (isset($updating['product_id'])) {
$product_id = $updating['product_id'];
}
if (mb_strlen($combination['sku']) > 255) {
$this->setErrorLengthRange("combination.$index.sku", $this->translation->text('SKU'), 0, 255);
return false;
}
if (isset($this->processed_skus[$combination['sku']])) {
$error = $this->translation->text('SKU must be unique per store');
$this->setError("combination.$index.sku", $error);
return false;
}
$store_id = $this->getSubmitted('store_id');
$existing = $this->sku->get(array('sku' => $combination['sku'], 'store_id' => $store_id));
if (isset($product_id) && isset($existing['product_id']) && $existing['product_id'] == $product_id) {
$this->processed_skus[$combination['sku']] = true;
return true;
}
if (!empty($existing)) {
$error = $this->translation->text('SKU must be unique per store');
$this->setError("combination.$index.sku", $error);
return false;
}
$this->processed_skus[$combination['sku']] = true;
return true;
} | Validates option combination SKUs
@param integer $index
@param array $combination
@return boolean|null | entailment |
protected function validateCombinationPriceProduct($index, &$combination)
{
$price = $this->getSubmitted('price');
if (empty($combination['price'])) {
$combination['price'] = $price;
}
if (!is_numeric($combination['price']) || strlen($combination['price']) > 10) {
$error = $this->translation->text('Only numeric values and no longer than @num characters', array('@num' => 10));
$this->setError("combination.$index.price", $error);
}
return !isset($error);
} | Validates combination stock price
@param integer $index
@param array $combination
@return boolean | entailment |
protected function validateCombinationStockProduct($index, &$combination)
{
if (empty($combination['stock'])) {
return null;
}
if (!is_numeric($combination['stock']) || strlen($combination['stock']) > 10) {
$error = $this->translation->text('Only numeric values and no longer than @num characters', array('@num' => 10));
$this->setError("combination.$index.stock", $error);
}
return !isset($error);
} | Validates combination stock level
@param integer $index
@param array $combination
@return null|boolean | entailment |
public function getList(array $options = array())
{
$result = null;
$this->hook->attach('sku.list.before', $options, $result, $this);
if (isset($result)) {
return $result;
}
$sql = 'SELECT ps.*, p.title, p.currency';
if (!empty($options['count'])) {
$sql = 'SELECT COUNT(ps.product_sku_id)';
}
$sql .= ' FROM product_sku ps LEFT JOIN product p ON(ps.product_id = p.product_id)';
$conditions = array();
if (isset($options['product_sku_id'])) {
$sql .= ' WHERE ps.product_sku_id = ?';
$conditions[] = $options['product_sku_id'];
} else {
$sql .= ' WHERE ps.product_sku_id IS NOT NULL';
}
if (isset($options['sku'])) {
$sql .= ' AND ps.sku=?';
$conditions[] = $options['sku'];
}
if (isset($options['store_id'])) {
$sql .= ' AND p.store_id=?';
$conditions[] = $options['store_id'];
}
if (isset($options['title_sku'])) {
$sql .= ' AND (p.title LIKE ? OR ps.sku LIKE ?)';
$conditions[] = "%{$options['title_sku']}%";
$conditions[] = "%{$options['title_sku']}%";
}
if (isset($options['product_id'])) {
$sql .= ' AND ps.product_id=?';
$conditions[] = $options['product_id'];
}
if (isset($options['combination_id'])) {
$sql .= ' AND ps.combination_id=?';
$conditions[] = $options['combination_id'];
}
if (isset($options['status'])) {
$sql .= ' AND ps.status=?';
$conditions[] = (int) $options['status'];
}
$sql .= " ORDER BY ps.sku ASC";
if (!empty($options['limit'])) {
$sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit']));
}
if (empty($options['count'])) {
$list = $this->db->fetchAll($sql, $conditions, array('index' => 'product_sku_id'));
$result = $this->prepareList($list);
} else {
$result = (int) $this->db->fetchColumn($sql, $conditions);
}
$this->hook->attach('sku.list.after', $options, $result, $this);
return $result;
} | Returns an array of SKUs or counts them
@param array $options
@return array|integer | entailment |
public function delete($product_id, array $options = array())
{
$result = null;
$this->hook->attach('sku.delete.before', $product_id, $options, $result, $this);
if (isset($result)) {
return (bool) $result;
}
$sql = 'DELETE FROM product_sku WHERE product_id=?';
if (!empty($options['combinations'])) {
$sql .= ' AND LENGTH(combination_id) > 0';
}
if (!empty($options['base'])) {
$sql .= ' AND LENGTH(combination_id) = 0';
}
$result = (bool) $this->db->run($sql, array($product_id))->rowCount();
$this->hook->attach('sku.delete.after', $product_id, $options, $result, $this);
return (bool) $result;
} | Deletes a product SKU
@param integer $product_id
@param array $options
@todo Refactor
@return boolean | entailment |
public function generate($pattern, array $options = array())
{
$options += array('store_id' => null, 'placeholders' => array());
$result = null;
$this->hook->attach('sku.generate.before', $pattern, $options, $result);
if (isset($result)) {
return (string) $result;
}
$sku = $pattern;
if (!empty($options['placeholders'])) {
$sku = gplcart_string_replace($pattern, $options['placeholders'], $options);
}
$result = $this->getUnique(mb_strimwidth($sku, 0, 200, ''), $options['store_id']);
$this->hook->attach('sku.generate.after', $pattern, $options, $result);
return $result;
} | Generates a SKU
@param string $pattern
@param array $options
@return string | entailment |
public function getUnique($sku, $store_id)
{
$existing = $this->get(array('sku' => $sku, 'store_id' => $store_id));
if (empty($existing)) {
return $sku;
}
$counter = 1;
do {
$modified = $sku . '-' . $counter;
$counter++;
} while ($this->get(array('sku' => $modified, 'store_id' => $store_id)));
return $modified;
} | Returns a unique SKU for the given store ID
@param string $sku
@param integer|null $store_id
@return string | entailment |
public function getFieldValues($combination_id)
{
$field_value_ids = explode('_', substr($combination_id, strpos($combination_id, '-') + 1));
sort($field_value_ids);
return $field_value_ids;
} | Returns an array of field value IDs from a combination ID
@param string $combination_id
@return array | entailment |
public function getCombinationId(array $field_value_ids, $product_id = null)
{
sort($field_value_ids);
$combination_id = implode('_', $field_value_ids);
return empty($product_id) ? $combination_id : "$product_id-$combination_id";
} | Creates a field combination id from an array of field value ids
@param array $field_value_ids
@param null|integer $product_id
@return string | entailment |
public function selectCombination(array $product, array $field_value_ids)
{
$result = array();
$this->hook->attach('sku.select.combination.before', $product, $field_value_ids, $result, $this);
if (!empty($result)) {
return (array) $result;
}
$access = !empty($product['stock']) || empty($product['subtract']);
$result = array(
'modal' => '',
'severity' => '',
'cart_access' => $access,
'combination' => array(),
'sku' => $product['sku'],
'price' => $product['price'],
'currency' => $product['currency'],
'message' => $access ? '' : $this->translation->text('Out of stock')
);
if (empty($field_value_ids)) {
$this->hook->attach('sku.select.combination.after', $product, $field_value_ids, $result, $this);
return (array) $result;
}
if (empty($product['status'])) {
$result['severity'] = 'danger';
$result['message'] = $this->translation->text('Unavailable');
$this->hook->attach('sku.select.combination.after', $product, $field_value_ids, $result, $this);
return (array) $result;
}
$combination_id = $this->getCombinationId($field_value_ids, $product['product_id']);
if (empty($product['combination'][$combination_id]['status'])) {
$result['not_matched'] = true;
$result['cart_access'] = false;
$result['severity'] = 'danger';
$result['message'] = $this->translation->text('Unavailable');
$result['related'] = $this->getRelatedFieldValues($product, $field_value_ids);
$this->hook->attach('sku.select.combination.after', $product, $field_value_ids, $result, $this);
return (array) $result;
}
$result['combination'] = $product['combination'][$combination_id];
$result['combination']['currency'] = $product['currency'];
$result['sku'] = $result['combination']['sku'];
$result['price'] = $result['combination']['price'];
if (empty($result['combination']['stock']) && $product['subtract']) {
$result['cart_access'] = false;
$result['severity'] = 'warning';
$result['message'] = $this->translation->text('Out of stock');
}
$this->hook->attach('sku.select.combination.after', $product, $field_value_ids, $result, $this);
return (array) $result;
} | Returns an array of data when selecting SKU combinations
@param array $product
@param array $field_value_ids
@return array | entailment |
protected function prepareList(array $list)
{
foreach ($list as &$item) {
$item['fields'] = $this->getFieldValues($item['combination_id']);
}
return $list;
} | Prepare an array of product SKU items
@param array $list
@return array | entailment |
protected function getRelatedFieldValues(array $product, array $ids)
{
$related = array();
foreach ($product['combination'] as $combination) {
if (array_intersect($ids, $combination['fields'])) {
$related += $combination['fields'];
}
}
return $related;
} | Returns an array of related fields value IDs
@todo Rethink this. It should return all possible combinations
@param array $product
@param array $ids
@return array | entailment |
protected function init()
{
parent::init();
$this->text = 'Submit';
$this->attributes['type'] = 'submit';
$this->attributes['id'] = !$this->name ? $this->attributes['id'] . 'submit' : $this->attributes['id'];
} | Initialize field settings | 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($validationRules['post_name'])){
$exploded = explode('|', $validationRules['post_name']);
$validationRules['post_name'] = [];
foreach($exploded as $key => $value){
$validationRules['post_name'][] = $value;
}
}
// Lets validate if a post_name is required.
if(!$post->disableDefaultPostName){
// If we are edditing the current existing post, we must remove the unique check
if($request->get('post_name') == $post->post_name){
$validationRules['post_name'] = 'required';
// If this is not a existing post name, we need to validate if its unique. They are changing the post name.
} else {
// Make sure that only the post_name of the requested post_type is unique
$validationRules['post_name'][] = 'required';
$validationRules['post_name'][] = Rule::unique('cms_posts')->where(function ($query) use ($post) {
return $query->where('post_type', $post->identifier);
});
}
}
$validator = Validator::make($request->all(), $validationRules);
if ($validator->fails()) {
return [
'status' => false,
'errors' => $validator->errors()
];
} else {
return true;
}
} | Validating the creation and change of a post | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$appName = 'PPI';
$mm = $this->getServiceManager()->get('ModuleManager');
$modules = $mm->getLoadedModules(true);
$output->writeln(sprintf('%s is running with <info>%d</info> modules loaded.', $appName, count($modules)));
foreach ($modules as $module) {
$output->writeln(PHP_EOL . '<info>' . $module->getName() . '</info>');
$output->writeln(' - <comment>namespace:</comment> ' . $module->getNamespace());
$output->writeln(' - <comment>path:</comment> ' . $module->getPath());
}
} | {@inheritdoc} | entailment |
public function accountOrder($user_id, $order_id)
{
$this->setUserAccountOrder($user_id);
$this->setOrderAccountOrder($order_id);
$this->setTitleAccountOrder();
$this->setBreadcrumbAccountOrder();
$this->setData('user', $this->data_user);
$this->setDataPanelSummaryAccountOrder();
$this->setDataPanelComponentsAccountOrder();
$this->setDataPanelPaymentAddressAccountOrder();
$this->setDataPanelShippingAddressAccountOrder();
$this->outputAccountOrder();
} | Page callback
Displays the order overview page
@param integer $user_id
@param integer $order_id | entailment |
protected function setBreadcrumbAccountOrder()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('/'),
'text' => $this->text('Shop')
);
$breadcrumbs[] = array(
'text' => $this->text('Orders'),
'url' => $this->url("account/{$this->data_user['user_id']}")
);
$this->setBreadcrumbs($breadcrumbs);
} | Sets breadcrumbs on the order overview page | entailment |
protected function setOrderAccountOrder($order_id)
{
$this->data_order = $this->order->get($order_id);
if (empty($this->data_order)) {
$this->outputHttpStatus(404);
}
$this->prepareOrderAccountOrder($this->data_order);
} | Sets an order data
@param integer $order_id | entailment |
protected function prepareOrderAccountOrder(array &$order)
{
$this->setItemTotalFormatted($order, $this->price);
$this->setItemOrderAddress($order, $this->address);
$this->setItemOrderStoreName($order, $this->store);
$this->setItemOrderStatusName($order, $this->order);
$this->setItemOrderPaymentName($order, $this->payment);
$this->setItemOrderShippingName($order, $this->shipping);
} | Prepare an array of order data
@param array $order | entailment |
protected function prepareOrderComponentsAccountOrder(array &$order)
{
$this->setItemOrderCartComponent($order, $this->price);
$this->setItemOrderPriceRuleComponent($order, $this->price, $this->price_rule);
$this->setItemOrderPaymentComponent($order, $this->price, $this->payment, $this->order);
$this->setItemOrderShippingComponent($order, $this->price, $this->shipping, $this->order);
ksort($order['data']['components']);
} | Prepare order components
@param array $order | entailment |
protected function setUserAccountOrder($user_id)
{
$this->data_user = $this->user->get($user_id);
if (empty($this->data_user)) {
$this->outputHttpStatus(404);
}
if (empty($this->data_user['status']) && !$this->access('user')) {
$this->outputHttpStatus(403);
}
} | Sets a user data
@param integer $user_id | entailment |
protected function setDataPanelComponentsAccountOrder()
{
$order = $this->data_order;
$this->prepareOrderComponentsAccountOrder($order);
$data = array(
'order' => $order,
'components' => $order['data']['components']
);
$this->setData('components', $this->render('account/order/components', $data));
} | Sets the order components panel on the order overview page | entailment |
public function viewHelp($hash)
{
$this->setFileHelp($hash);
$this->setTitleViewHelp();
$this->setBreadcrumbViewHelp();
$this->setData('help', $this->renderHelp());
$this->outputViewHelp();
} | View a help item
@param string $hash | entailment |
protected function setTitleViewHelp()
{
$meta = $this->help->getMeta($this->data_file);
$this->setTitle($meta['title']);
} | Sets titles on the view help page | entailment |
protected function setBreadcrumbViewHelp()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'url' => $this->url('admin/help'),
'text' => $this->text('Help')
);
$this->setBreadcrumbs($breadcrumbs);
} | Sets breadcrumbs on the view help page | entailment |
protected function setFileHelp($hash)
{
$this->data_file = gplcart_path_absolute(gplcart_string_decode($hash));
if (!is_file($this->data_file)) {
$this->outputHttpStatus(404);
}
} | Sets help file path
@param string $hash | entailment |
public function listHelp()
{
$this->setTitleListHelp();
$this->setBreadcrumbListHelp();
$this->setData('items', $this->getListHelp());
$this->outputListHelp();
} | Displays the help list page | entailment |
protected function setBreadcrumbListHelp()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$this->setBreadcrumbs($breadcrumbs);
} | Sets breadcrumbs on the help list page | entailment |
public function isMet(array $trigger, array $data)
{
$result = null;
$this->hook->attach('condition.met.before', $trigger, $data, $result, $this);
if (isset($result)) {
return (bool) $result;
}
if (empty($trigger['data']['conditions'])) {
return false;
}
$result = true;
$this->processed = array();
foreach ($trigger['data']['conditions'] as $condition) {
if ($this->callHandler($condition, $data) !== true) {
$result = false;
break;
}
$this->processed[] = $condition['id'];
}
$this->hook->attach('condition.met.after', $trigger, $data, $result, $this);
return (bool) $result;
} | Whether all conditions are met
@param array $trigger
@param array $data
@return boolean | entailment |
protected function callHandler(array $condition, array $data)
{
try {
$handlers = $this->getHandlers();
return Handler::call($handlers, $condition['id'], 'process', array($condition, $data, $this));
} catch (Exception $ex) {
return false;
}
} | Call a condition handler
@param array $condition
@param array $data
@return bool | entailment |
public function getOperators()
{
return array(
"<" => $this->translation->text('Less than'),
">" => $this->translation->text('Greater than'),
"=" => $this->translation->text('Equal (is in list)'),
"<=" => $this->translation->text('Less than or equal to'),
">=" => $this->translation->text('Greater than or equal to'),
"!=" => $this->translation->text('Not equal (is not in list)')
);
} | Returns an array of condition operators
@return array | entailment |
public function init($group)
{
// Lets validate if the post type exists and if so, continue.
$postTypeModel = $this->getPostType($group);
if(!$postTypeModel){
$errorMessages = 'You are not authorized to do this.';
return $this->abort($errorMessages);
}
// Receiving the current data of the group
$config = NikuConfig::where('group', '=', $group)
->get()
->keyBy('option_name')
->toArray();
$templates = $postTypeModel->view;
// Appending the key added in the config to the array
// so we can use it very easliy in the component.
foreach($templates as $key => $template){
if(!empty($template['customFields'])){
// For each custom fields
foreach($template['customFields'] as $ckey => $customField){
$templates[$key]['customFields'][$ckey]['id'] = $ckey;
// Adding the values to the result
if(!empty($config[$ckey])){
$templates[$key]['customFields'][$ckey]['value'] = $config[$ckey]['option_value'];
}
}
}
}
$collection = collect([
'config' => $this->getConfig($postTypeModel),
'templates' => $templates,
]);
return response()->json($collection);
} | Display a single post | entailment |
public function fieldValue(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateFieldValue();
$this->validateTitle();
$this->validateWeight();
$this->validateTranslation();
$this->validateFieldFieldValue();
$this->validateColorFieldValue();
$this->validateUploadImages('field_value');
$this->unsetSubmitted('update');
$this->unsetSubmitted('field');
return $this->getResult();
} | Performs full field value data validation
@param array $submitted
@param array $options
@return boolean|array | entailment |
protected function validateFieldValue()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->field_value->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Field value'));
return false;
}
$this->setUpdating($data);
return true;
} | Validates a field value to be updated
@return boolean|null | entailment |
protected function validateColorFieldValue()
{
$field = 'color';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if (!isset($value) || $value === '') {
return null;
}
if (preg_match('/#([a-fA-F0-9]{3}){1,2}\b/', $value) !== 1) {
$this->setErrorInvalid($field, $this->translation->text('Color'));
return false;
}
// HTML5 color field cannot have empty value
// Default value is #000000
// Assuming black is empty
if ($value === '#000000') {
$this->setSubmitted($field, '');
}
return true;
} | Validates a color code
@return boolean|null | entailment |
public function getNextWeight($type, $pos)
{
$step = 20;
$count = $this->count($type, $pos);
return $count * $step + $step;
} | Returns a weight for the next asset
@param string $type
@param string $pos
@return integer | entailment |
public function getMaxWeight($type, $pos)
{
if (empty($this->assets[$type][$pos])) {
return null;
}
$weights = array();
foreach ($this->assets[$type][$pos] as $asset) {
$weights[] = $asset['weight'];
}
return max($weights);
} | Returns the max weight of added assets
@param string $type
@param string $pos
@return int|null | entailment |
public function count($type, $pos)
{
return empty($this->assets[$type][$pos]) ? 0 : count($this->assets[$type][$pos]);
} | Returns a weight of the last added asset
@param string $type Either "css" or "js"
@param string $pos Either "top" or "bottom"
@return integer | entailment |
public function get($type, $position)
{
if (empty($this->assets[$type][$position])) {
return array();
}
return $this->assets[$type][$position];
} | Returns an array of asset items
@param string $type
@param string $position
@return array | entailment |
public function set(array $data)
{
$build = $this->build($data);
if (empty($build['asset'])) {
return false;
}
if (!empty($build['merge']) && is_array($build['asset'])) {
if (isset($this->assets[$build['type']][$build['position']][$build['merge']])) {
$existing = $this->assets[$build['type']][$build['position']][$build['merge']]['asset'];
$this->assets[$build['type']][$build['position']][$build['merge']]['asset'] = array_merge($existing, $build['asset']);
}
}
if (isset($this->assets[$build['type']][$build['position']][$build['key']])) {
return false;
}
$this->assets[$build['type']][$build['position']][$build['key']] = $build;
return $this->assets[$build['type']];
} | Sets an asset
@param array $data
@return bool|array | entailment |
public function build(array $data)
{
if (is_array($data['asset'])) {
$type = 'js';
} else if (strpos($data['asset'], 'http') === 0) {
$type = 'external';
} else {
$type = pathinfo($data['asset'], PATHINFO_EXTENSION);
}
$data += array(
'file' => '',
'key' => null,
'merge' => '',
'version' => '',
'type' => $type,
'text' => false,
'condition' => '',
'position' => 'top'
);
if (!isset($data['weight'])) {
$data['weight'] = $this->getNextWeight($data['type'], $data['position']);
}
if (!in_array($data['type'], array('css', 'js'))) {
$data['text'] = true;
}
if (($type !== 'external' && $type != $data['type']) || is_array($data['asset'])) {
$data['text'] = true; // Arrays will be converted to JSON
}
if ($data['text']) {
if (!isset($data['key'])) {
$data['key'] = 'text.' . md5(json_encode($data['asset']));
}
return $data;
}
if (gplcart_path_is_absolute($data['asset'])) {
$data['file'] = $data['asset'];
$data['asset'] = gplcart_path_relative($data['asset']);
} else if ($type !== 'external') {
$data['file'] = gplcart_path_absolute($data['asset']);
}
if (!empty($data['file'])) {
if (!file_exists($data['file'])) {
return array();
}
$data['version'] = filemtime($data['file']);
}
$data['key'] = $data['asset'] = str_replace('\\', '/', $data['asset']);
return $data;
} | Builds asset data
@param array $data
@return array | entailment |
public function listModule()
{
$this->actionListModule();
$this->setTitleListModule();
$this->setBreadcrumbListModule();
$this->setFilterListModule();
$this->setPagerListModule();
$this->setData('types', $this->getTypesModule());
$this->setData('modules', (array) $this->getListModule());
$this->setData('available_modules', $this->module->getList());
$this->outputListModule();
} | Displays the module admin overview page | entailment |
protected function actionListModule()
{
$this->controlToken('action');
$action = $this->getQuery('action');
$module_id = $this->getQuery('module_id');
if (!empty($action) && !empty($module_id)) {
$this->setModule($module_id);
$result = $this->startActionModule($action);
$this->finishActionModule($result);
}
} | Applies an action to a module | entailment |
protected function setModule($module_id)
{
$this->data_module = $this->module->get($module_id);
if (empty($this->data_module)) {
$this->outputHttpStatus(403);
}
} | Set a module data
@param string $module_id | entailment |
protected function finishActionModule($result)
{
if ($result === true) {
$this->redirect('', $this->text('Module has been updated'), 'success');
}
$message = $result ? $result : $this->text('Operation unavailable');
$this->redirect('', $message, 'danger');
} | Finishes module action
@param mixed $result | entailment |
protected function startActionModule($action)
{
$this->controlAccess("module_$action");
switch ($action) {
case 'enable':
return $this->module_model->enable($this->data_module['id']);
case 'disable':
return $this->module_model->disable($this->data_module['id']);
case 'install':
return $this->module_model->install($this->data_module['id']);
case 'uninstall':
return $this->module_model->uninstall($this->data_module['id']);
}
$this->outputHttpStatus(403);
return null;
} | Performs an action against a module
@param string $action
@return mixed | entailment |
protected function getListModule($count = false)
{
$list = $this->module->getList();
$this->checkDependenciesListModule($list);
$this->prepareListModule($list);
$allowed = $this->getAllowedFiltersModule();
$this->filterList($list, $allowed, $this->query_filter);
$this->sortList($list, $allowed, $this->query_filter, array('id' => 'asc'));
if ($count) {
return count($list);
}
$this->limitList($list, $this->data_limit);
return $list;
} | Returns an array of modules
@param bool $count
@return array|int | entailment |
protected function prepareListModule(array &$list)
{
foreach ($list as &$item) {
$item['has_dependencies'] = !empty($item['requires']) || !empty($item['required_by']);
}
} | Prepare an array of modules
@param array $list | entailment |
protected function checkDependenciesListModule(array &$list)
{
$this->validateDependencies($list);
$list = $this->graph->build($list);
} | Validates module dependencies
@param array $list | entailment |
protected function getTypesModule()
{
$types = array();
foreach ($this->module->getList() as $module) {
$types[$module['type']] = $this->text(ucfirst($module['type']));
}
return $types;
} | Returns an array of module types
@return array | entailment |
protected function setPagerListModule()
{
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->getListModule(true)
);
return $this->data_limit = $this->setPager($pager);
} | Sets pager
@return array | entailment |
public function run()
{
$result = null;
$this->hook->attach('cron.run.before', $result, $this);
if (isset($result)) {
return (bool) $result;
}
ini_set('max_execution_time', 0);
register_shutdown_function(array($this, 'shutdownHandler'));
$this->logger->log('cron', 'Cron has started', 'info');
try {
$result = $this->process();
} catch (Exception $ex) {
$this->logger->log('cron', $ex->getMessage(), 'danger', false);
$result = false;
}
$this->hook->attach('cron.run.after', $result, $this);
$this->config->set('cron_last_run', GC_TIME);
return (bool) $result;
} | Run cron tasks
@return bool | entailment |
public function process()
{
$this->report->deleteExpired();
$this->history->deleteExpired();
// Delete files in temporary directory
foreach (gplcart_file_scan_recursive(GC_DIR_PRIVATE_TEMP) as $file) {
if (strpos(basename($file), '.') !== 0) { // Ignore hidden files
gplcart_file_delete_recursive($file);
}
}
$result = $this->report->checkFilesystem();
if ($result !== true) {
foreach ((array) $result as $message) {
$this->logger->log('system_status', array('message' => $message), 'warning');
}
}
return true;
} | Processes all defined tasks
@return bool | entailment |
protected function outputCommandListHelp()
{
$routes = $this->route->getList();
ksort($routes);
$rows = array(
array(
$this->text('Command'),
$this->text('Alias'),
$this->text('Description')
)
);
foreach ($routes as $command => $info) {
$rows[] = array(
$command,
empty($info['alias']) ? '' : $info['alias'],
empty($info['description']) ? '' : $info['description']
);
}
$this->table($rows);
$this->output();
} | Output a list of all available CLI commands | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.