sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function render($name, array $parameters = array())
{
try {
return $this->load($name)->render($parameters);
} catch (\Twig_Error $e) {
if ($name instanceof TemplateReference) {
try {
// try to get the real file name of the template w... | Renders a template.
@param mixed $name A template name
@param array $parameters An array of parameters to pass to the template
@throws \InvalidArgumentException if the template does not exist
@throws \RuntimeException if the template cannot be rendered
@return string The evaluated template as a string | entailment |
public function renderResponse($view, array $parameters = array(), Response $response = null)
{
if (null === $response) {
$response = new Response();
}
$response->setContent($this->render($view, $parameters));
return $response;
} | Renders a view and returns a Response.
@param string $view The view name
@param array $parameters An array of parameters to pass to the view
@param Response $response A Response instance
@return Response A Response instance | entailment |
protected function load($name)
{
if ($name instanceof \Twig_Template) {
return $name;
}
try {
return $this->environment->loadTemplate($name);
} catch (\Twig_Error_Loader $e) {
throw new \InvalidArgumentException($e->getMessage(), $e->getCode(), $e... | Loads the given template.
@param mixed $name A template name or an instance of Twig_Template
@throws \InvalidArgumentException if the template does not exist
@return \Twig_TemplateInterface A \Twig_TemplateInterface instance | entailment |
public function generate($pattern, array $options = array())
{
$options += array(
'translit' => true,
'language' => null,
'placeholders' => array()
);
$result = null;
$this->hook->attach('alias.generate.before', $pattern, $options, $result);
... | Generate a URL alias using a pattern and an array of data
@param string $pattern
@param array $options
@return string | entailment |
public function generateEntity($entity, array $data)
{
$handlers = $this->getHandlers();
if (isset($handlers[$entity]['mapping']) && isset($handlers[$entity]['pattern'])) {
$data += array('placeholders' => $handlers[$entity]['mapping']);
return $this->generate($handlers[$ent... | Generates an alias for an entity
@param string $entity
@param array $data
@return string|null | entailment |
public function loadEntity($entity, $entity_id)
{
try {
$handlers = $this->getHandlers();
return Handler::call($handlers, $entity, 'data', array($entity_id));
} catch (Exception $ex) {
return array();
}
} | Returns an array of entity data
@param string $entity
@param int $entity_id
@return array | entailment |
public function getUnique($alias)
{
if (!$this->exists($alias)) {
return $alias;
}
$info = pathinfo($alias);
$ext = isset($info['extension']) ? '.' . $info['extension'] : '';
$counter = 0;
do {
$counter++;
$modified = $info['file... | Returns a unique alias using a base string
@param string $alias
@return string | entailment |
public function exists($path)
{
foreach ($this->route->getList() as $route) {
if (isset($route['pattern']) && $route['pattern'] === $path) {
return true;
}
}
return (bool) $this->get(array('alias' => $path));
} | Whether the alias path already exists
@param string $path
@return boolean | entailment |
protected function getSubmitted($key = null, $default = null)
{
if (!isset($key)) {
return $this->submitted;
}
$path = $this->getKeyPath($key);
if (isset($path)) {
$result = gplcart_array_get($this->submitted, $path);
return isset($result) ? $res... | Returns a submitted value
@param null|string $key
@param mixed $default
@return mixed | entailment |
public function setSubmitted($key, $value)
{
gplcart_array_set($this->submitted, $this->getKeyPath($key), $value);
} | Sets a value to an array of submitted values
@param string $key
@param mixed $value | entailment |
protected function getUpdatingId($key = 'update')
{
if (empty($this->submitted[$key]) || is_array($this->submitted[$key])) {
return false;
}
return $this->submitted[$key];
} | Returns either an ID of entity to be updated or false if no ID found (adding).
It also returns false if an array of updating entity has been loaded and set
@param string $key
@return boolean|string|integer | entailment |
protected function getKeyPath($key)
{
if (empty($this->options['parents'])) {
return $key;
}
if (is_string($this->options['parents'])) {
$this->options['parents'] = explode('.', $this->options['parents']);
}
if (is_string($key)) {
$key = ... | Returns an array that represents a path to a nested array value
@param string|array $key
@return array | entailment |
protected function isExcluded($field)
{
return isset($this->options['field']) && $this->options['field'] !== $this->getKey($field);
} | Whether the field should be excluded from validation
@param string $field
@return bool | entailment |
protected function setError($key, $error)
{
gplcart_array_set($this->errors, $this->getKeyPath($key), $error);
return $this->errors;
} | Sets a validation error
@param string|array $key
@param string $error
@return array | entailment |
protected function isError($key = null)
{
if (!isset($key)) {
return !empty($this->errors);
}
$result = $this->getError($key);
return !empty($result);
} | Whether an error exists
@param string|null $key
@return boolean | entailment |
protected function getResult()
{
$result = empty($this->errors) ? true : $this->errors;
$this->errors = array();
return $result;
} | Returns validation results
@return array|boolean | entailment |
public function product(array $condition, array $data)
{
$is_product = (int) isset($data['product_id']);
$value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
return $this->compare($is_product, $value, $condition['operator']);
} | Whether the product scope condition is met
@param array $condition
@param array $data
@return boolean | entailment |
public function cart(array $condition, array $data)
{
$is_cart = (int) isset($data['cart_id']);
$value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
return $this->compare($is_cart, $value, $condition['operator']);
} | Whether the cart scope condition is met
@param array $condition
@param array $data
@return boolean | entailment |
public function order(array $condition, array $data)
{
$is_order = (int) isset($data['order_id']);
$value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
return $this->compare($is_order, $value, $condition['operator']);
} | Whether the order scope condition is met
@param array $condition
@param array $data
@return boolean | entailment |
public function editInstall()
{
$this->controlAccessInstall();
$this->translation->set($this->install_language, null);
$this->setTitleEditInstall();
$requirements = $this->getRequirementsInstall();
$issues = $this->getRequirementErrorsInstall($requirements);
$this->... | Displays the installation page | entailment |
protected function getLanguagesInstall()
{
$languages = array();
foreach ($this->language->getList() as $code => $language) {
if ($code === 'en' || is_file($this->translation->getFile($code))) {
$languages[$code] = $language;
}
}
return $lang... | Returns an array of existing languages
@return array | entailment |
protected function processInstall()
{
$result = $this->install->process($this->getSubmitted());
$this->redirect($result['redirect'], $result['message'], $result['severity']);
} | Performs all needed operations to install the system | entailment |
protected function validateEditInstall()
{
$this->setSubmitted('settings');
$this->setSubmitted('store.host', $this->server->httpHost());
$this->setSubmitted('store.language', $this->install_language);
$this->setSubmitted('store.basepath', trim($this->request->base(true), '/'));
... | Validates an array of submitted form values
@return bool | entailment |
public function indexAccount($user_id)
{
$this->setUserAccount($user_id);
$this->setTitleIndexAccount();
$this->setBreadcrumbIndexAccount();
$this->setFilter();
$this->setPagerOrderIndexAccount();
$this->setData('user', $this->data_user);
$this->setData('ord... | Page callback
Displays the user account page
@param integer $user_id | entailment |
protected function setPagerOrderIndexAccount()
{
$conditions = array(
'count' => true,
'user_id' => $this->data_user['user_id']
);
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->order->getList($conditions),
... | Sets pager
@return array | entailment |
protected function getListOrderAccount()
{
$conditions = $this->query_filter;
$conditions['order'] = 'desc';
$conditions['sort'] = 'created';
$conditions['limit'] = $this->data_limit;
$conditions['user_id'] = $this->data_user['user_id'];
$list = (array) $this->order-... | Returns an array of orders for the user
@return array | entailment |
protected function prepareListOrderAccount(array &$list)
{
foreach ($list as &$item) {
$this->setItemTotalFormatted($item, $this->price);
$this->setItemOrderAddress($item, $this->address);
$this->setItemOrderStoreName($item, $this->store);
$this->setItemOrderS... | Prepare an array of orders
@param array $list | entailment |
public function editAccount($user_id)
{
$this->setUserAccount($user_id);
$this->controlAccessEditAccount();
$this->setTitleEditAccount();
$this->setBreadcrumbEditAccount();
$this->setData('user', $this->data_user);
$this->submitEditAccount();
$this->outputEdi... | Page callback
Displays the edit account page
@param integer $user_id | entailment |
protected function updateAccount()
{
$this->controlAccessEditAccount();
if ($this->user->update($this->data_user['user_id'], $this->getSubmitted())) {
$this->redirect('', $this->text('Account has been updated'), 'success');
}
$this->redirect('', $this->text('Account has... | Updates a user | entailment |
protected function setBreadcrumbEditAccount()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('/'),
'text' => $this->text('Shop')
);
$breadcrumbs[] = array(
'text' => $this->text('Account'),
'url' => $this->url("... | Sets breadcrumbs on the edit account page | entailment |
public function init(Request $request, $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);
}
// Recieving the value... | The manager of the database communication for adding and manipulating posts | entailment |
public function editUserForgot()
{
$this->controlAccessUserForgot();
$this->setUserForgot();
$this->setTitleEditUserForgot();
$this->setBreadcrumbEditUserForgot();
$this->setData('forgetful_user', $this->data_user);
$this->setData('password_limit', $this->user->getP... | Displays the password reset page | entailment |
protected function setUserForgot()
{
$token = $this->getQuery('key');
$user_id = $this->getQuery('user_id');
$this->data_user = array();
if (!empty($token) && is_numeric($user_id)) {
$this->data_user = $this->user->get($user_id);
$this->controlTokenUserForgo... | Returns a user from the current reset password URL | entailment |
protected function controlTokenUserForgot($user, $token)
{
if (!empty($user['status'])) {
if (empty($user['data']['reset_password']['token'])) {
$this->redirect('forgot');
}
if (!gplcart_string_equals($user['data']['reset_password']['token'], $token)) {
... | Validates the token and its expiration time set for the user
@param array $user
@param string $token | entailment |
protected function resetPasswordUser()
{
$result = $this->user_action->resetPassword($this->getSubmitted());
$this->redirect($result['redirect'], $result['message'], $result['severity']);
} | Reset user's password | entailment |
protected function validateUserForgot()
{
$this->setSubmitted('user', null, false);
$this->filterSubmitted(array('email', 'password'));
$this->setSubmitted('user', $this->data_user);
$this->validateComponent('user_reset_password');
return !$this->hasErrors();
} | Validates a submitted data when a user wants to reset its password
@return boolean | entailment |
public function countryState(array $submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateCountryState();
$this->validateBool('status');
$this->validateCodeCountryState();
$this->validateName();
$this... | Performs full country state validation
@param array $submitted
@param array $options
@return array|boolean | entailment |
protected function validateCountryState()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->state->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Country state'));
... | Validates a state to be updated
@return boolean|null | entailment |
public function validateCodeCountryState()
{
$field = 'code';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating() && !isset($value)) {
$this->unsetSubmitted($field);
return null;
... | Validates a state code
@return boolean | entailment |
protected function validateZoneCountryState()
{
$field = 'zone_id';
$value = $this->getSubmitted($field);
if (empty($value)) {
return null;
}
$label = $this->translation->text('Zone');
if (!is_numeric($value)) {
$this->setErrorNumeric($field... | Validates a zone ID
@return boolean|null | entailment |
public function required(array $submitted, array $options)
{
$options += array(
'field' => null,
'label' => null
);
$value = gplcart_array_get($submitted, $options['field']);
if (empty($value)) {
return $this->setErrorRequired($options['field'], ... | Validates the field/value is not empty
@param array $submitted
@param array $options
@return bool|array | entailment |
public function numeric(array $submitted, array $options)
{
$options += array(
'field' => null,
'label' => null
);
$value = gplcart_array_get($submitted, $options['field']);
if (is_numeric($value)) {
return true;
}
return $this->... | Validates the field/value is numeric
@param array $submitted
@param array $options
@return bool|array | entailment |
public function integer(array $submitted, array $options)
{
$options += array(
'field' => null,
'label' => null
);
$value = gplcart_array_get($submitted, $options['field']);
if (filter_var($value, FILTER_VALIDATE_INT) === false) {
return $this->s... | Validates the field/value contains only digits
@param array $submitted
@param array $options
@return bool|array | entailment |
public function length(array $submitted, array $options)
{
$options += array(
'field' => null,
'label' => null,
'arguments' => array()
);
$value = gplcart_array_get($submitted, $options['field']);
list($min, $max) = $options['arguments'] + array(... | Validates the field/value length
@param array $submitted
@param array $options
@return bool|array | entailment |
public function regexp(array $submitted, array $options)
{
$options += array(
'field' => null,
'label' => null,
'arguments' => array()
);
$value = gplcart_array_get($submitted, $options['field']);
if (empty($options['arguments']) || preg_match(re... | Validates the field/value matches a regexp pattern
@param array $submitted
@param array $options
@return bool|array | entailment |
public function dateformat(array $submitted, array $options)
{
$options += array(
'field' => null,
'label' => null
);
$value = gplcart_array_get($submitted, $options['field']);
if (strtotime($value) === false) {
return $this->setErrorInvalid($opt... | Validates the date format
@param array $submitted
@param array $options
@link http://php.net/manual/en/function.strtotime.php
@return bool|array | entailment |
public function json(array $submitted, array $options)
{
$options += array(
'field' => null,
'label' => null
);
$value = gplcart_array_get($submitted, $options['field']);
json_decode($value);
if (json_last_error() === JSON_ERROR_NONE) {
... | Validates the field/value is a JSON string
@param array $submitted
@param array $options
@return array|bool | entailment |
public function id(array $condition, array $data)
{
if (empty($data['product_id'])) {
return false;
}
return $this->compare($data['product_id'], $condition['value'], $condition['operator']);
} | Whether the product ID condition is met
@param array $condition
@param array $data
@return boolean | entailment |
public function categoryId(array $condition, array $data)
{
if (empty($data['product_id']) || empty($data['category_id'])) {
return false;
}
return $this->compare($data['category_id'], $condition['value'], $condition['operator']);
} | Whether the product category ID condition is met
@param array $condition
@param array $data
@return boolean | entailment |
public function brandCategoryId(array $condition, array $data)
{
if (empty(empty($data['product_id']) || $data['brand_category_id'])) {
return false;
}
return $this->compare($data['brand_category_id'], $condition['value'], $condition['operator']);
} | Whether the product brand condition is met
@param array $condition
@param array $data
@return boolean | 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);
}
if... | Display a single post | entailment |
protected function retrieveConfigPostMetas($post, $postTypeModel)
{
$metaKeys = [];
$metaTaxonomies = [];
$allKeys = $this->getValidationsKeys($postTypeModel);
foreach($allKeys as $key => $value){
$customFieldObject = $this->getCustomFieldObject($postTypeModel, $key);
if(isset($customFieldObject['type... | Get all the post meta keys of the post | entailment |
protected function mergeCollectionWithView($view, $collection, $postTypeModel)
{
$post = $collection['post'];
$postmeta = $collection['postmeta'];
// Foreaching all templates in the custom field configuration file
foreach($view as $templateKey => $template){
// If the array custom fields is... | Appending the key added in the config to the array
so we can use it very easliy in the component. | entailment |
public function productClassField(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateProductClassField();
$this->validateProductClassProductClassField();
$this->validateWeight();
$this->validateBoo... | Performs full product class field validation
@param array $submitted
@param array $options
@return array|boolean | entailment |
protected function validateProductClassField()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->product_class_field->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Addre... | Validates a product class field to be updated
@return boolean | entailment |
protected function validateProductClassProductClassField()
{
$field = 'product_class_id';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating() && !isset($value)) {
$this->unsetSubmitted($field... | Validates a product class ID
@return boolean|null | entailment |
protected function validateFieldIdProductClassField()
{
$field = 'field_id';
if ($this->isExcluded($field) || $this->isError('product_class_id')) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating() && !isset($value)) {
$th... | Validates one or several field IDs
@return bool|null | entailment |
public function load($file, $type = null)
{
$path = $this->locator->locate($file);
$content = $this->loadFile($path);
// empty file
if (null === $content) {
return array();
}
// imports (Symfony)
$content = $this->parseImports($content, $path)... | Loads a Yaml file.
@param mixed $file The resource
@param string $type The resource type
@throws \InvalidArgumentException
@return array Array with configuration | entailment |
protected function parseImports($content, $file)
{
if (!isset($content['imports'])) {
return $content;
}
foreach ($content['imports'] as $import) {
$this->setCurrentDir(dirname($file));
$content = ArrayUtils::merge($this->import($import['resource'], null,... | Parses all imports. We support this to make Symfony users happy.
@param array $content
@param string $file
@return array | entailment |
protected function parseIncludes(array $content, $file)
{
foreach ($content as $key => $value) {
if (is_array($value)) {
$content[$key] = $this->parseIncludes($value, $file);
}
if ('@include' === trim($key)) {
$this->setCurrentDir(dirname(... | Process the array for @include. We support this to make Zend users happy.
@see http://framework.zend.com/manual/2.0/en/modules/zend.config.reader.html#zend-config-reader-yaml
@param array $content
@param string $file
@return array | entailment |
public function getAssetUrlBlock(array $parameters = array(), $path = null, $template, &$repeat)
{
// only output on the closing tag
if (!$repeat) {
$parameters = array_merge(array(
'package' => null,
), $parameters);
return $this->helper->getUrl(... | Returns the public path of an asset. Absolute paths (i.e. http://...) are
returned unmodified.
@param array $parameters
@param type $path
@param type $template
@param type $repeat
@return string A public path which takes into account the base path and URL path | entailment |
public function getAssetsVersion(array $parameters = array(), \Smarty_Internal_Template $template)
{
$parameters = array_merge(array(
'package' => null,
), $parameters);
return $this->helper->getVersion($parameters['package']);
} | Returns the version of the assets in a package.
@param array $parameters
@param \Smarty_Internal_Template $template
@return int | entailment |
public function add(array $data)
{
$result = null;
$this->hook->attach('user.add.before', $data, $result, $this);
if (isset($result)) {
return (int) $result;
}
if (empty($data['name'])) {
$data['name'] = strtok($data['email'], '@');
}
... | Adds a user
@param array $data
@return integer | entailment |
public function update($user_id, array $data)
{
$result = null;
$this->hook->attach('user.update.before', $user_id, $data, $result, $this);
if (isset($result)) {
return (bool) $result;
}
$data['modified'] = GC_TIME;
if (!empty($data['password'])) {
... | Updates a user
@param integer $user_id
@param array $data
@return boolean * | entailment |
public function canDelete($user_id)
{
if ($this->isSuperadmin($user_id)) {
return false;
}
$result = $this->db->fetchColumn('SELECT * FROM orders WHERE user_id=?', array($user_id));
return empty($result);
} | Whether the user can be deleted
@param integer $user_id
@return boolean | entailment |
public function isSuperadmin($user_id = null)
{
if (isset($user_id)) {
return $this->getSuperadminId() == $user_id;
}
return $this->getSuperadminId() == $this->uid;
} | Whether the user is super admin
@param integer|null $user_id
@return boolean | entailment |
public function access($permission, $user_id = null)
{
if ($this->isSuperadmin($user_id)) {
return true;
}
if ($permission === GC_PERM_SUPERADMIN) {
return false;
}
return in_array($permission, $this->getPermissions($user_id));
} | Whether a user has an access to do something
@param string $permission
@param null|int $user_id
@return boolean | entailment |
public function getPermissions($user_id = null)
{
static $permissions = array();
if (!isset($user_id)) {
$user_id = $this->uid;
}
if (isset($permissions[$user_id])) {
return $permissions[$user_id];
}
$user = $this->get($user_id);
if... | Returns user permissions
@param null|integer $user_id
@return array | entailment |
public function getSession($key = null)
{
$user = $this->session->get('user', array());
if (isset($key)) {
return gplcart_array_get($user, $key);
}
return $user;
} | Returns the current user from the session
@param array|string $key
@return mixed | entailment |
public function passwordMatches($password, $user)
{
if (!is_array($user)) {
$user = $this->get($user);
}
if (empty($user['hash'])) {
return false;
}
return gplcart_string_equals($user['hash'], gplcart_string_hash($password, $user['hash'], 0));
} | Whether the password matches the user's password stored in the database
@param string $password
@param array|int $user
@return boolean | entailment |
protected function deleteLinked($user_id)
{
$this->db->delete('cart', array('user_id' => $user_id));
$this->db->delete('review', array('user_id' => $user_id));
$this->db->delete('history', array('user_id' => $user_id));
$this->db->delete('address', array('user_id' => $user_id));
... | Deletes all database records related to the user ID
@param int $user_id | entailment |
protected function setAddress(array $data)
{
if (empty($data['addresses'])) {
return false;
}
foreach ($data['addresses'] as $address) {
if (empty($address['address_id'])) {
$address['user_id'] = $data['user_id'];
$this->address->add($... | Adds/updates addresses for the user
@param array $data
@return boolean | entailment |
public function set($cid, $data)
{
$result = null;
$this->hook->attach('cache.set.before', $cid, $data, $result, $this);
if (isset($result)) {
return $result;
}
if (is_array($cid)) {
$cid = gplcart_array_hash($cid);
}
$this->file = G... | Set cache
@param string|array $cid
@param mixed $data
@return boolean | entailment |
public function get($cid, $options = array())
{
$options += array(
'lifespan' => 0,
'default' => null
);
$result = null;
$this->hook->attach('cache.get.before', $cid, $options, $result, $this);
if (isset($result)) {
return $result;
... | Returns a cached data
@param string|array $cid
@param array $options
@return mixed | entailment |
public function clear($cache_id, $options = array())
{
$result = null;
$options += array('pattern' => '.cache');
$this->hook->attach('cache.clear.before', $cache_id, $options, $result, $this);
if (isset($result)) {
return $result;
}
$result = true;
... | Clears a cached data
@param string|null|array $cache_id
@param array $options
@return bool | entailment |
protected function getImageStyleFieldsSettings()
{
return array(
'image_style_category' => $this->text('Category page'),
'image_style_category_child' => $this->text('Category page (child)'),
'image_style_product' => $this->text('Product page'),
'image_style_pa... | Returns an array of image style settings keys and their corresponding field labels
@return array | entailment |
protected function submitSettings()
{
if ($this->isPosted('reset')) {
$this->resetSettings();
} else if ($this->isPosted('save') && $this->validateSettings()) {
$this->updateSettings();
}
} | Saves the submitted settings | entailment |
protected function resetSettings()
{
$this->controlAccess('module_edit');
$this->module->setSettings('frontend', array());
$this->redirect('', $this->text('Settings have been reset to default values'), 'success');
} | Resets module settings to default values | entailment |
protected function setBreadcrumbEditSettings()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'text' => $this->text('Dashboard'),
'url' => $this->url('admin')
);
$breadcrumbs[] = array(
'text' => $this->text('Modules'),
'url' => $t... | Sets bread crumbs on the module settings page | entailment |
public function editUserRole($role_id = null)
{
$this->setUserRole($role_id);
$this->setTitleEditUserRole();
$this->setBreadcrumbEditUserRole();
$this->setData('role', $this->data_role);
$this->setData('permissions', $this->getPermissionsUserRole(true));
$this->subm... | Displays the user role edit page
@param integer|null $role_id | entailment |
protected function getPermissionsUserRole($chunked = false)
{
$permissions = $this->role->getPermissions();
return $chunked ? gplcart_array_split($permissions, 3) : $permissions;
} | Returns an array of permissions
@param bool $chunked
@return array | entailment |
protected function setUserRole($role_id)
{
$this->data_role = array();
if (is_numeric($role_id)) {
$this->data_role = $this->role->get($role_id);
if (empty($this->data_role)) {
$this->outputHttpStatus(404);
}
}
} | Returns a user role data
@param integer|null $role_id | entailment |
protected function submitEditUserRole()
{
if ($this->isPosted('delete')) {
$this->deleteUserRole();
} else if ($this->isPosted('save') && $this->validateEditUserRole()) {
if (isset($this->data_role['role_id'])) {
$this->updateUserRole();
} else {
... | Handles a submitted user role data | entailment |
protected function validateEditUserRole()
{
$this->setSubmitted('role');
$this->setSubmittedBool('status');
$this->setSubmitted('update', $this->data_role);
if (!$this->getSubmitted('permissions')) {
$this->setSubmitted('permissions', array());
}
$this->... | Validates a submitted user role data
@return boolean | entailment |
protected function deleteUserRole()
{
$this->controlAccess('user_role_delete');
if ($this->role->delete($this->data_role['role_id'])) {
$this->redirect('admin/user/role', $this->text('Role has been deleted'), 'success');
}
$this->redirect('', $this->text('Role has not b... | Deletes a user role | entailment |
protected function updateUserRole()
{
$this->controlAccess('user_role_edit');
if ($this->role->update($this->data_role['role_id'], $this->getSubmitted())) {
$this->redirect('admin/user/role', $this->text('Role has been updated'), 'success');
}
$this->redirect('', $this-... | Updates a user role | entailment |
protected function addUserRole()
{
$this->controlAccess('user_role_add');
if ($this->role->add($this->getSubmitted())) {
$this->redirect('admin/user/role', $this->text('Role has been added'), 'success');
}
$this->redirect('', $this->text('Role has not been added'), 'war... | Adds a new user role | entailment |
protected function setTitleEditUserRole()
{
if (isset($this->data_role['role_id'])) {
$title = $this->text('Edit %name', array('%name' => $this->data_role['name']));
} else {
$title = $this->text('Add role');
}
$this->setTitle($title);
} | Sets titles on the user role edit page | entailment |
protected function setBreadcrumbEditUserRole()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'text' => $this->text('Roles'),
'url' => $thi... | Sets breadcrumbs on the user role edit page | entailment |
public function listUserRole()
{
$this->actionListUserRole();
$this->setTitleListUserRole();
$this->setBreadcrumbListUserRole();
$this->setFilterListUserRole();
$this->setPagerListUserRole();
$this->setData('user_roles', $this->getListUserRole());
$this->outp... | Displays the user role overview page | entailment |
protected function setPagerListUserRole()
{
$options = $this->query_filter;
$options['count'] = true;
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->role->getList($options)
);
return $this->data_limit = $this->setPager($pager... | Sets pager
@return array | entailment |
protected function actionListUserRole()
{
list($selected, $action, $value) = $this->getPostedAction();
$deleted = $updated = 0;
foreach ($selected as $role_id) {
if ($action === 'status' && $this->access('user_role_edit')) {
$updated += (int) $this->role->updat... | Applies an action to the selected user roles | entailment |
protected function getListUserRole()
{
$conditions = $this->query_filter;
$conditions['limit'] = $this->data_limit;
$list = (array) $this->role->getList($conditions);
$this->prepareListUserRole($list);
return $list;
} | Returns an array of user roles
@return array | entailment |
protected function prepareListUserRole(array &$roles)
{
$permissions = $this->getPermissionsUserRole();
foreach ($roles as &$role) {
if (!empty($role['permissions'])) {
$list = array_intersect_key($permissions, array_flip($role['permissions']));
$role['pe... | Prepare an array of user roles
@param array $roles | entailment |
protected static function deserializeCommonAttributes(array $data)
{
$result = new static(isset($data['id']) ? $data['id'] : null);
if ($result->getResourceType() != $data['meta']['resourceType']) {
throw new \RuntimeException(sprintf('Error deserializing resource type "%s" into class "%... | @param array $data
@return static | entailment |
public function setTranslations(array $data, $model, $entity, $delete_existing = true)
{
if (empty($data['translation']) || empty($data["{$entity}_id"]) || !$model->isSupportedEntity($entity)) {
return null;
}
foreach ($data['translation'] as $language => $translation) {
... | Deletes and/or adds translations
@param array $data
@param \gplcart\core\models\TranslationEntity $model
@param string $entity
@param bool $delete_existing
@return boolean | entailment |
public function handle($request, Closure $next, $acceptedGroups)
{
$acceptedGroups = explode('|', $acceptedGroups);
// Lets verify that we are authorized to use this post type
if(!in_array($request->route('group'), $acceptedGroups)){
$message = $request->route('post_type') . ' config group is... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@param string|null $guard
@return mixed | entailment |
public function init(Request $request, $postType, $id, $customFieldKey)
{
$postTypeModel = $this->getPostType($postType);
if(!$postTypeModel){
$errorMessages = 'You are not authorized to do this.';
return $this->abort($errorMessages);
}
// Check if the post type has a identifier
if(em... | The manager of the database communication for adding and manipulating posts | entailment |
protected function validatePost($request, $post, $validationRules)
{
$currentValidationRuleKeys = [];
foreach($request->all() as $requestKey => $requestValue){
$currentValidationRuleKeys[$requestKey] = $requestKey;
}
$validationRules = $this->validateFieldByConditionalLogic($validationRules, $post, ... | Validating the creation and change of a post | entailment |
public function listCity($country_code, $state_id)
{
$this->setStateCity($state_id);
$this->setCountryCity($country_code);
$this->actionListCity();
$this->setTitleListCity();
$this->setBreadcrumbListCity();
$this->setFilterListCity();
$this->setPagerListCity... | Displays the city overview page
@param string $country_code
@param integer $state_id | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.