code
stringlengths 52
7.75k
| docs
stringlengths 1
5.85k
|
---|---|
public function databaseBackups($site, $env, $db)
{
$variables = array(
'site' => $site,
'env' => $env,
'db' => $db,
);
$request = $this->get(array('{+base_path}/sites/{site}/envs/{env}/dbs/{db}/backups.json', $variables));
return new Response\DatabaseBackups($request);
}
|
@param string $site
@param string $env
@param string $db
@return \Acquia\Cloud\Api\Response\DatabaseBackups
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#GET__sites__site_envs__env_dbs__db_backups-instance_route
|
public function databaseBackup($site, $env, $db, $backupId)
{
$variables = array(
'site' => $site,
'env' => $env,
'db' => $db,
'id' => $backupId,
);
$request = $this->get(array('{+base_path}/sites/{site}/envs/{env}/dbs/{db}/backups/{id}.json', $variables));
return new Response\DatabaseBackup($request);
}
|
@param string $site
@param string $env
@param string $db
@param int $backupId
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#GET__sites__site_envs__env_dbs__db_backups__backup-instance_route
|
public function deleteDatabaseBackup($site, $env, $db, $backupId)
{
$variables = array(
'site' => $site,
'env' => $env,
'db' => $db,
'backup' => $backupId,
);
$request = $this->delete(array('{+base_path}/sites/{site}/envs/{env}/dbs/{db}/backups/{backup}.json', $variables));
return new Response\Task($request);
}
|
@param string $site
@param string $env
@param string $db
@param int $backupId
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#DELETE__sites__site_envs__env_dbs__db_backups__backup-instance_route
|
public function downloadDatabaseBackup($site, $env, $db, $backupId, $outfile)
{
$variables = array(
'site' => $site,
'env' => $env,
'db' => $db,
'id' => $backupId,
);
return $this
->get(array('{+base_path}/sites/{site}/envs/{env}/dbs/{db}/backups/{id}/download.json', $variables))
->setResponseBody($outfile)
->send()
;
}
|
@param string $site
@param string $env
@param string $db
@param int $backupId
@param string $outfile
@return \Guzzle\Http\Message\Response
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#GET__sites__site_envs__env_dbs__db_backups__backup_download-instance_route
|
public function createDatabaseBackup($site, $env, $db)
{
$variables = array(
'site' => $site,
'env' => $env,
'db' => $db,
);
$request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/dbs/{db}/backups.json', $variables));
return new Response\Task($request);
}
|
@param string $site
@param string $env
@param string $db
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#POST__sites__site_envs__env_dbs__db_backups-instance_route
|
public function restoreDatabaseBackup($site, $env, $db, $backupId)
{
$variables = array(
'site' => $site,
'env' => $env,
'db' => $db,
'id' => $backupId,
);
$request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/dbs/{db}/backups/{id}/restore.json', $variables));
return new Response\Task($request);
}
|
@param string $site
@param string $env
@param string $db
@param string $backupId
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#POST__sites__site_envs__env_dbs__db_backups__backup_restore-instance_route
|
public function tasks($site)
{
$variables = array(
'site' => $site,
);
$request = $this->get(array('{+base_path}/sites/{site}/tasks.json', $variables));
return new Response\Tasks($request);
}
|
@param string $site
@return \Acquia\Cloud\Api\Response\Tasks
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#GET__sites__site_tasks-instance_route
|
public function task($site, $taskId)
{
$variables = array(
'site' => $site,
'task' => $taskId,
);
$request = $this->get(array('{+base_path}/sites/{site}/tasks/{task}.json', $variables));
return new Response\Task($request);
}
|
@param string $site
@param int $taskId
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#GET__sites__site_tasks__task-instance_route
|
public function domains($site, $env)
{
$variables = array(
'site' => $site,
'env' => $env,
);
$request = $this->get(array('{+base_path}/sites/{site}/envs/{env}/domains.json', $variables));
return new Response\Domains($request);
}
|
@param string $site
@param string $env
@return \Acquia\Cloud\Api\Response\Domains
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#GET__sites__site_envs__env_domains-instance_route
|
public function domain($site, $env, $domain)
{
$variables = array(
'site' => $site,
'env' => $env,
'domain' => $domain,
);
$request = $this->get(array('{+base_path}/sites/{site}/envs/{env}/domains/{domain}.json', $variables));
return new Response\Domain($request);
}
|
@param string $site
@param string $env
@param string $domain
@return \Acquia\Cloud\Api\Response\Domain
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#GET__sites__site_envs__env_domains__domain-instance_route
|
public function addDomain($site, $env, $domain)
{
$variables = array(
'site' => $site,
'env' => $env,
'domain' => $domain,
);
$request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/domains/{domain}.json', $variables));
return new Response\Task($request);
}
|
@param string $site
@param string $env
@param string $domain
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#POST__sites__site_envs__env_domains__domain-instance_route
|
public function moveDomain($site, $domains, $sourceEnv, $targetEnv, $skipSiteUpdate = FALSE)
{
$paths = '{+base_path}/sites/{site}/domain-move/{source}/{target}.json';
$update_site = '';
if ($skipSiteUpdate) {
$update_site = '1';
$paths .= '?skip_site_update={update_site}';
}
$variables = array(
'site' => $site,
'source' => $sourceEnv,
'target' => $targetEnv,
'update_site' => $update_site,
);
$body = Json::encode(array('domains' => (array) $domains));
$request = $this->post(array($paths, $variables), null, $body);
return new Response\Task($request);
}
|
Moves domains atomically from one environment to another.
@param string $site
The site.
@param string|array $domains
The domain name(s) as an array of strings, or the string '*' to move all
domains.
@param string $sourceEnv
The environment which currently has this domain.
@param string $targetEnv
The destination environment for the domain.
@param bool $skipSiteUpdate
Optional. If set to TRUE this will inhibit running
fields-config-web.php for this domain move.
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#POST__sites__site_domain_move__source__target-instance_route
|
public function deleteDomain($site, $env, $domain)
{
$variables = array(
'site' => $site,
'env' => $env,
'domain' => $domain,
);
$request = $this->delete(array('{+base_path}/sites/{site}/envs/{env}/domains/{domain}.json', $variables));
return new Response\Task($request);
}
|
@param string $site
@param string $env
@param string $domain
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#DELETE__sites__site_envs__env_domains__domain-instance_route
|
public function copyDatabase($site, $db, $sourceEnv, $targetEnv)
{
$variables = array(
'site' => $site,
'db' => $db,
'source' => $sourceEnv,
'target' => $targetEnv,
);
$request = $this->post(array('{+base_path}/sites/{site}/dbs/{db}/db-copy/{source}/{target}.json', $variables));
return new Response\Task($request);
}
|
@param string $site
@param string $db
@param string $sourceEnv
@param string $targetEnv
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#POST__sites__site_dbs__db_db_copy__source__target-instance_route
|
public function liveDev($site, $env, $action, $discard = false)
{
$variables = array(
'site' => $site,
'env' => $env,
'action' => $action,
'discard' => (int) $discard,
);
$request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/livedev/{action}.json?discard={discard}', $variables));
return new Response\Task($request);
}
|
@param string $site
@param string $env
@param string $action
@param bool $discard
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#POST__sites__site_envs__env_livedev__action-instance_route
|
public function enableLiveDev($site, $env, $discard = false)
{
return $this->liveDev($site, $env, self::LIVEDEV_ENABLE, $discard);
}
|
@param string $site
@param string $env
@param bool $discard
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
|
public function disableLiveDev($site, $env, $discard = false)
{
return $this->liveDev($site, $env, self::LIVEDEV_DISABLE, $discard);
}
|
@param string $site
@param string $env
@param bool $discard
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
|
public function deployCode($site, $sourceEnv, $targetEnv)
{
$variables = array(
'site' => $site,
'source' => $sourceEnv,
'target' => $targetEnv,
);
$request = $this->post(array('{+base_path}/sites/{site}/code-deploy/{source}/{target}.json', $variables));
return new Response\Task($request);
}
|
Deploy code from on environment to another.
@param string $site
@param string $sourceEnv
@param string $targetEnv
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#POST__sites__site_code_deploy__source__target-instance_route
|
public function pushCode($site, $env, $vcsPath)
{
$variables = array(
'site' => $site,
'env' => $env,
'path' => $vcsPath,
);
$request = $this->post(array('{+base_path}/sites/{site}/envs/{env}/code-deploy.json?path={path}', $variables));
return new Response\Task($request);
}
|
Deploy a tag or branch to an environment.
@param string $site
@param string $env
@param string $vcsPath
@return \Acquia\Cloud\Api\Response\Task
@throws \Guzzle\Http\Exception\ClientErrorResponseException
@see http://cloudapi.acquia.com/#POST__sites__site_envs__env_code_deploy-instance_route
|
private function resolveDataClass(FormInterface $form)
{
// Nothing to do if root
if ($form->isRoot()) {
return $form->getConfig()->getDataClass();
}
$propertyPath = $form->getPropertyPath();
/** @var FormInterface $dataForm */
$dataForm = $form;
// If we have a index then we need to use it's parent
if ($propertyPath->getLength() === 1 && $propertyPath->isIndex(0) && $form->getConfig()->getCompound()) {
return $this->resolveDataClass($form->getParent());
}
// Now locate the closest data class
// TODO what is the length really for?
for ($i = $propertyPath->getLength(); $i !== 0; $i--) {
$dataForm = $dataForm->getParent();
# When a data class is found then use that form
# This happend when property_path contains multiple parts aka `entity.prop`
if ($dataForm->getConfig()->getDataClass() !== null) {
break;
}
}
// If the root inherits data, then grab the parent
if ($dataForm->getConfig()->getInheritData()) {
$dataForm = $dataForm->getParent();
}
return $dataForm->getConfig()->getDataClass();
}
|
Gets the form root data class used by the given form.
@param FormInterface $form
@return string|null
|
private function resolveDataSource(FormInterface $form)
{
if ($form->isRoot()) {
// Nothing to do if root
$dataForm = $form->getData();
} else {
$dataForm = $form;
while ($dataForm->getConfig()->getDataClass() === null) {
$dataForm = $form->getParent();
}
}
$data = $dataForm->getData();
return array(
$data,
$data === null ? $dataForm->getConfig()->getDataClass() : get_class($data)
);
}
|
Gets the form data to which a property path applies
@param FormInterface $form
@return object|null
|
private function guessProperty(ClassMetadata $metadata, $element)
{
// Is it the element the actual property
if ($metadata->hasPropertyMetadata($element)) {
return $element;
}
// Is it a camelized property
$camelized = $this->camelize($element);
if ($metadata->hasPropertyMetadata($camelized)) {
return $camelized;
}
return null;
}
|
Guess what property a given element belongs to.
@param ClassMetadata $metadata
@param string $element
@return null|string
|
public function process(ContainerBuilder $container)
{
$this->registerRuleProcessors($container);
$this->registerRuleCompilers($container);
$this->registerRuleMappers($container);
}
|
{@inheritDoc}
|
public function credentials()
{
$creds = $this->cloudEnvironment->serviceCredentials();
if (!isset($creds['memcached_servers'])) {
throw new \OutOfBoundsException('Memcache credentials not found');
}
$servers = array();
foreach ($creds['memcached_servers'] as $id => $url) {
$data = parse_url($url);
$servers[$id] = new MemcacheCredentials($data);
}
return $servers;
}
|
{@inheritDoc}
|
public function addCollection(RuleCollection $collection)
{
foreach ($collection as $name => $rule) {
$this->set($name, $rule);
}
}
|
Adds a rule collection at the end of the current set by appending all
rule of the added collection.
@param RuleCollection $collection A RuleCollection instance
|
public function compare( $operator, $key, $value )
{
$this->conditions[] = $this->filter->compare( $operator, $key, $value );
return $this;
}
|
Adds generic condition for filtering
@param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
@param string $key Search key defined by the locale manager, e.g. "locale.status"
@param array|string $value Value or list of values to compare to
@return \Aimeos\Controller\Frontend\Locale\Iface Locale controller for fluent interface
@since 2019.04
|
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('boekkooi_jquery_validation');
$rootNode->append($this->loadFormNode());
$rootNode->append($this->loadTwigNode());
return $treeBuilder;
}
|
{@inheritDoc}
|
public function boot()
{
parent::boot();
$this->publishConfig();
SettingsManager::$runsMigrations ? $this->loadMigrations() : $this->publishMigrations();
}
|
Boot the service provider.
|
private function registerSettingsManager()
{
$this->singleton(Contracts\Manager::class, function ($app) {
return new SettingsManager($app);
});
$this->singleton(Contracts\Store::class, function ($app) {
/** @var \Arcanedev\LaravelSettings\Contracts\Manager $manager */
$manager = $app[Contracts\Manager::class];
return $manager->driver();
});
}
|
Register the Settings Manager.
|
public function addDatabaseCredentials($acquiaDbName, $localDbName, $username, $password = null, $host = 'localhost', $port = 3306)
{
$connString = $username;
if ($password !== null) {
$connString . ':' . $password;
}
$this->creds['databases'][$acquiaDbName] = array(
'id' => '1',
'role' => $this->sitegroup, // Is this right? For local doesn't really matter.
'name' => $localDbName,
'user' => $username,
'pass' => $password,
'db_url_ha' => array(
$host => "mysqli://$connString@$host:$port/mysiteprod"
),
'db_cluster_id' => '1',
'port' => $port,
);
return $this;
}
|
Adds credentials to a database server.
@param string $acquiaDbName
@param string $localDbName
@param string $username
@param string|null $password
@param string $host
@param integer $port
@return \Acquia\Cloud\Environment\LocalEnvironment
|
public function setObject( \Aimeos\Controller\Frontend\Iface $object )
{
$this->object = $object;
return $this;
}
|
Injects the reference of the outmost object
@param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
@return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
|
public function generate($string)
{
$data = $this->getRequestTime() . $this->generateNonce() . $string;
return hash_hmac('sha1', $data, $this->getSecretKey());
}
|
{@inheritdoc}
|
public function compare( $operator, $key, $value )
{
$this->controller->compare( $operator, $key, $value );
return $this;
}
|
Adds generic condition for filtering attributes
@param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
@param string $key Search key defined by the catalog manager, e.g. "catalog.status"
@param array|string $value Value or list of values to compare to
@return \Aimeos\Controller\Frontend\Catalog\Iface Catalog controller for fluent interface
@since 2019.04
|
public function getTree( $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE )
{
return $this->controller->getTree( $level );
}
|
Returns the categories filtered by the previously assigned conditions
@param integer $level Constant from \Aimeos\MW\Tree\Manager\Base, e.g. LEVEL_ONE, LEVEL_LIST or LEVEL_TREE
@return \Aimeos\MShop\Catalog\Item\Iface Category tree
@since 2019.04
|
public function save( \Aimeos\MShop\Subscription\Item\Iface $item )
{
return $this->controller->save( $item );
}
|
Saves the modified subscription item
@param \Aimeos\MShop\Subscription\Item\Iface $item Subscription object
@return \Aimeos\MShop\Subscription\Item\Iface Saved subscription item
|
protected function buttonsViewData(FormRuleContext $context)
{
$buttonNames = $context->getButtons();
$buttons = array();
foreach ($buttonNames as $name) {
$groups = $context->getGroup($name);
$buttons[] = array(
'name' => $name,
'cancel' => count($groups) === 0,
'validation_groups' => $groups,
);
}
return $buttons;
}
|
Transform the buttons in the given form into a array that can easily be used by twig.
@param FormRuleContext $context
@return array
|
public function load( $id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true )
{
return $this->controller->load( $id, $parts, $default );
}
|
Returns the order base object for the given ID
@param string $id Unique ID of the order base object
@param integer $parts Constants which parts of the order base object should be loaded
@param boolean $default True to add default criteria (user logged in), false if not
@return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts
|
public function addProduct( \Aimeos\MShop\Product\Item\Iface $product, $quantity = 1,
array $variant = [], array $config = [], array $custom = [], $stocktype = 'default', $supplier = null )
{
$this->controller->addProduct( $product, $quantity, $variant, $config, $custom, $stocktype, $supplier );
return $this;
}
|
Adds a product to the basket of the customer stored in the session
@param \Aimeos\MShop\Product\Item\Iface $product Product to add including texts, media, prices, attributes, etc.
@param integer $quantity Amount of products that should by added
@param array $variant List of variant-building attribute IDs that identify an article in a selection product
@param array $config List of configurable attribute IDs the customer has chosen from
@param array $custom Associative list of attribute IDs as keys and arbitrary values that will be added to the ordered product
@param string $stocktype Unique code of the stock type to deliver the products from
@param string|null $supplier Unique supplier code the product is from
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
@throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
|
public function addAddress( $type, array $values = [], $position = null )
{
$this->controller->addAddress( $type, $values, $position );
return $this;
}
|
Adds an address of the customer to the basket
@param string $type Address type code like 'payment' or 'delivery'
@param array $values Associative list of key/value pairs with address details
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
|
public function deleteAddress( $type, $position = null )
{
$this->controller->deleteAddress( $type, $position );
return $this;
}
|
Removes the address of the given type and position if available
@param string $type Address type code like 'payment' or 'delivery'
@param integer|null $position Position of the address in the list to overwrite
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
|
public function addService( \Aimeos\MShop\Service\Item\Iface $service, array $config = [], $position = null )
{
$this->controller->addService( $service, $config, $position );
return $this;
}
|
Adds the delivery/payment service including the given configuration
@param \Aimeos\MShop\Service\Item\Iface $service Service item selected by the customer
@param array $config Associative list of key/value pairs with the options selected by the customer
@param integer|null $position Position of the address in the list to overwrite
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
@throws \Aimeos\Controller\Frontend\Basket\Exception If given service attributes are invalid
|
public function deleteService( $type, $position = null )
{
$this->controller->deleteService( $type, $position );
return $this;
}
|
Removes the delivery or payment service items from the basket
@param string $type Service type code like 'payment' or 'delivery'
@param integer|null $position Position of the address in the list to overwrite
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
|
public static function getValidationGroups(FormInterface $form)
{
$cfg = $form->getConfig();
if ($cfg->hasOption('jquery_validation_groups')) {
$groups = $cfg->getOption('jquery_validation_groups');
} else {
$groups = $cfg->getOption('validation_groups');
}
# Is the default validation group used
if ($groups === null) {
return array(Constraint::DEFAULT_GROUP);
}
# Is the validation suppressed
if ($groups === false) {
return array();
}
# Is a unsupported group used
if (!is_string($groups) && is_callable($groups)) {
throw new UnsupportedException('Callable validation_groups are not supported. Disable jquery_validation or set jquery_validation_groups');
}
return (array) $groups;
}
|
Retrieve the (jquery) validation groups that are configured for the given FormInterface instance.
@param FormInterface $form
@return array|null|false
|
public function processMenu(ItemInterface $menu, array $options = []): ItemInterface
{
// Dispatch Event
if ($menu->isEvent()) {
$this->eventDispatcher->dispatch($menu->getId() . '.event', new PdMenuEvent($menu));
}
// Set Current URI
$this->currentUri = $this->router->getContext()->getPathInfo();
// Process Menu
$this->recursiveProcess($menu, $options);
return $menu;
}
|
Menu Processor.
@param ItemInterface $menu
@param array $options
@return ItemInterface
|
private function recursiveProcess(ItemInterface $menu, $options)
{
// Get Child Menus
$childs = $menu->getChild();
// Parent Menu Route
if (isset($menu->getChildAttr()['data-parent'])) {
$menu->setChildAttr(['data-parent' => $this->router->generate($menu->getChildAttr()['data-parent'])]);
}
// Sort Current Child
foreach ($childs as $child) {
// Generate Route Link
if ($child->getRoute()) {
$child->setLink($this->router->generate($child->getRoute()['name'], $child->getRoute()['params']));
// Link Active Class
if ($this->currentUri === $child->getLink()) {
$child->setListAttr(array_merge_recursive($child->getListAttr(), ['class' => $options['currentClass']]));
}
}
// Item Security
if ($child->getRoles()) {
if (!$this->security->isGranted($child->getRoles())) {
unset($childs[$child->getId()]);
}
}
// Set Child Process
if ($child->getChild()) {
// Set Menu Depth
if (null !== $options['depth'] && ($child->getLevel() >= $options['depth'])) {
$child->setChild([]);
break;
}
// Set Child List Class
$child->setChildAttr(array_merge_recursive($child->getChildAttr(), ['class' => 'menu_level_' . $child->getLevel()]));
$this->recursiveProcess($child, $options);
}
}
// Sort Item
usort($childs, function ($a, $b) {
return $a->getOrder() > $b->getOrder();
});
// Set Childs
$menu->setChild($childs);
}
|
Process Menu Item.
@param ItemInterface $menu
@param $options
|
protected function postOptions(array $options)
{
$this->manager = new RedisManager(
$this->app, Arr::pull($options, 'client', 'predis'), $options
);
}
|
Fire the post options to customize the store.
@param array $options
|
protected function hash()
{
$string = '';
for ($i = 0; $i < $this->length; $i++) {
$string .= chr(mt_rand(32, 126));
}
return base64_encode($string);
}
|
{@inheritdoc}
|
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
{
if (!$this->supports($constraint, $form)) {
throw new LogicException();
}
/** @var \Symfony\Component\Validator\Constraints\Choice|\Symfony\Component\Validator\Constraints\Length $constraint */
$collection->set(
self::RULE_NAME,
new ConstraintRule(
self::RULE_NAME,
$constraint->max,
new RuleMessage($constraint->maxMessage, array('{{ limit }}' => $constraint->max), (int) $constraint->max),
$constraint->groups
)
);
}
|
{@inheritdoc}
|
protected function checkListRef( $prodId, $domain, array $refMap )
{
if( empty( $refMap ) ) {
return;
}
$context = $this->getContext();
$productManager = \Aimeos\MShop::create( $context, 'product' );
$search = $productManager->createSearch( true );
$expr = [$search->getConditions()];
$expr[] = $search->compare( '==', 'product.id', $prodId );
foreach( $refMap as $listType => $refIds )
{
foreach( $refIds as $refId )
{
$cmpfunc = $search->createFunction( 'product:has', [$domain, $listType, (string) $refId] );
$expr[] = $search->compare( '!=', $cmpfunc, null );
}
}
$search->setConditions( $search->combine( '&&', $expr ) );
if( count( $productManager->searchItems( $search, [] ) ) === 0 )
{
$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid "%1$s" references for product with ID %2$s' );
throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, json_encode( $prodId ) ) );
}
}
|
Checks if the reference IDs are really associated to the product
@param string|array $prodId Unique ID of the product or list of product IDs
@param string $domain Domain the references must be of
@param array $refMap Associative list of list type codes as keys and lists of reference IDs as values
@throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
|
protected function checkLocale( \Aimeos\MShop\Locale\Item\Iface $locale, $type )
{
$errors = [];
$context = $this->getContext();
$session = $context->getSession();
$localeStr = $session->get( 'aimeos/basket/locale' );
$localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId();
if( $localeStr !== null && $localeStr !== $localeKey )
{
$locParts = explode( '|', $localeStr );
$locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' );
$locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' );
$locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' );
$localeManager = \Aimeos\MShop::create( $context, 'locale' );
$locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false );
$context = clone $context;
$context->setLocale( $locale );
$manager = \Aimeos\MShop\Order\Manager\Factory::create( $context )->getSubManager( 'base' );
$basket = $manager->getSession( $type )->off();
$this->copyAddresses( $basket, $errors, $localeKey );
$this->copyServices( $basket, $errors );
$this->copyProducts( $basket, $errors, $localeKey );
$this->copyCoupons( $basket, $errors, $localeKey );
$manager->setSession( $basket, $type );
}
$session->set( 'aimeos/basket/locale', $localeKey );
}
|
Checks for a locale mismatch and migrates the products to the new basket if necessary.
@param \Aimeos\MShop\Locale\Item\Iface $locale Locale object from current basket
@param string $type Basket type
|
protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
{
foreach( $basket->getAddresses() as $type => $items )
{
foreach( $items as $pos => $item )
{
try
{
$this->getObject()->get()->addAddress( $item, $type, $pos );
}
catch( \Exception $e )
{
$logger = $this->getContext()->getLogger();
$errors['address'][$type] = $e->getMessage();
$str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s';
$logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
}
}
$basket->deleteAddress( $type );
}
return $errors;
}
|
Migrates the addresses from the old basket to the current one.
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
@param array $errors Associative list of previous errors
@param string $localeKey Unique identifier of the site, language and currency
@return array Associative list of errors occured
|
protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
{
foreach( $basket->getCoupons() as $code => $list )
{
try
{
$this->getObject()->addCoupon( $code );
$basket->deleteCoupon( $code, true );
}
catch( \Exception $e )
{
$logger = $this->getContext()->getLogger();
$errors['coupon'][$code] = $e->getMessage();
$str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
}
}
return $errors;
}
|
Migrates the coupons from the old basket to the current one.
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
@param array $errors Associative list of previous errors
@param string $localeKey Unique identifier of the site, language and currency
@return array Associative list of errors occured
|
protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'service' );
foreach( $basket->getServices() as $type => $list )
{
foreach( $list as $item )
{
try
{
$attributes = [];
foreach( $item->getAttributeItems() as $attrItem ) {
$attributes[$attrItem->getCode()] = $attrItem->getValue();
}
$service = $manager->getItem( $item->getServiceId(), ['media', 'price', 'text'] );
$this->getObject()->addService( $service, $attributes );
$basket->deleteService( $type );
}
catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
}
}
return $errors;
}
|
Migrates the services from the old basket to the current one.
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
@param array $errors Associative list of previous errors
@return array Associative list of errors occured
|
protected function createSubscriptions( \Aimeos\MShop\Order\Item\Base\Iface $basket )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'subscription' );
foreach( $basket->getProducts() as $orderProduct )
{
if( ( $interval = $orderProduct->getAttribute( 'interval', 'config' ) ) !== null )
{
$item = $manager->createItem()->setInterval( $interval )
->setOrderProductId( $orderProduct->getId() )
->setOrderBaseId( $basket->getId() );
if( ( $end = $orderProduct->getAttribute( 'intervalend', 'custom' ) ) !== null
|| ( $end = $orderProduct->getAttribute( 'intervalend', 'config' ) ) !== null
|| ( $end = $orderProduct->getAttribute( 'intervalend', 'hidden' ) ) !== null
) {
$item = $item->setDateEnd( $end );
}
$manager->saveItem( $item, false );
}
}
}
|
Creates the subscription entries for the ordered products with interval attributes
@param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
|
protected function getAttributes( array $attributeIds, array $domains = ['text'] )
{
if( empty( $attributeIds ) ) {
return [];
}
$attributeManager = \Aimeos\MShop::create( $this->getContext(), 'attribute' );
$search = $attributeManager->createSearch( true );
$expr = array(
$search->compare( '==', 'attribute.id', $attributeIds ),
$search->getConditions(),
);
$search->setConditions( $search->combine( '&&', $expr ) );
$search->setSlice( 0, count( $attributeIds ) );
$attrItems = $attributeManager->searchItems( $search, $domains );
if( count( $attrItems ) !== count( $attributeIds ) )
{
$i18n = $this->getContext()->getI18n();
$expected = implode( ',', $attributeIds );
$actual = implode( ',', array_keys( $attrItems ) );
$msg = $i18n->dt( 'controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"' );
throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $actual, $expected ) );
}
return $attrItems;
}
|
Returns the attribute items for the given attribute IDs.
@param array $attributeIds List of attribute IDs
@param string[] $domains Names of the domain items that should be fetched too
@return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface
@throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one
|
protected function getAttributeItems( array $orderAttributes )
{
if( empty( $orderAttributes ) ) {
return [];
}
$attributeManager = \Aimeos\MShop::create( $this->getContext(), 'attribute' );
$search = $attributeManager->createSearch( true );
$expr = [];
foreach( $orderAttributes as $item )
{
$tmp = array(
$search->compare( '==', 'attribute.domain', 'product' ),
$search->compare( '==', 'attribute.code', $item->getValue() ),
$search->compare( '==', 'attribute.type', $item->getCode() ),
$search->compare( '>', 'attribute.status', 0 ),
$search->getConditions(),
);
$expr[] = $search->combine( '&&', $tmp );
}
$search->setConditions( $search->combine( '||', $expr ) );
return $attributeManager->searchItems( $search, array( 'price' ) );
}
|
Returns the attribute items using the given order attribute items.
@param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items
@return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values
|
protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] )
{
$list = [];
if( !empty( $ids ) )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'order/base/product/attribute' );
foreach( $this->getAttributes( $ids ) as $id => $attrItem )
{
$list[] = $manager->createItem()->copyFrom( $attrItem )->setType( $type )
->setValue( isset( $values[$id] ) ? $values[$id] : $attrItem->getCode() )
->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 );
}
}
return $list;
}
|
Returns the order product attribute items for the given IDs and values
@param string $type Attribute type code
@param array $ids List of attributes IDs of the given type
@param array $values Associative list of attribute IDs as keys and their codes as values
@param array $quantities Associative list of attribute IDs as keys and their quantities as values
@return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
|
protected function getenv($key)
{
$value = getenv($key);
if ($value === false) {
if (isset($_ENV[$key])) {
$value = $_ENV[$key];
}
if (isset($_SERVER[$key])) {
$value = $_SERVER[$key];
}
}
return $value;
}
|
Acquia Cloud variables may be set in settings.inc after PHP init,
so make sure that we are loading them.
@param string $key
@return string The value of the environment variable or false if not found
@see https://github.com/acquia/acquia-sdk-php/pull/58#issuecomment-45167451
|
public function getSiteGroup()
{
if (!isset($this->sitegroup)) {
$this->sitegroup = $this->getenv('AH_SITE_GROUP');
if (!$this->sitegroup) {
throw new \UnexpectedValueException('Expecting environment variable AH_SITE_GROUP to be set');
}
}
return $this->sitegroup;
}
|
@rturn string
@throws \UnexpectedValueException
|
public function serviceCredentials()
{
if (!isset($this->creds)) {
$filepath = $this->getCredentialsFilepath();
$this->creds = Json::parseFile($filepath);
}
return $this->creds;
}
|
@return array
@throws \RuntimeException
|
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
{
if (!$this->supports($constraint, $form)) {
throw new LogicException();
}
/** @var File $constraint */
$collection->set(
self::RULE_NAME,
new ConstraintRule(
self::RULE_NAME,
implode(',', $constraint->mimeTypes),
new RuleMessage($constraint->mimeTypesMessage, array(
'{{ types }}' => implode(', ', $constraint->mimeTypes),
)),
$constraint->groups
)
);
}
|
{@inheritdoc}
|
public function set($key, $value)
{
$this->assertConstraintInstance($value);
parent::set($key, $value);
}
|
{@inheritDoc}
@param Constraint $value A Constraint instance
|
protected function postOptions(array $options)
{
$this->model = $this->app->make(
Arr::get($options, 'model', SettingModel::class)
);
$this->setConnection(Arr::get($options, 'connection', null));
$this->setTable(Arr::get($options, 'table', 'settings'));
$this->setKeyColumn(Arr::get($options, 'columns.key', 'key'));
$this->setValueColumn(Arr::get($options, 'columns.value', 'value'));
}
|
Fire the post options to customize the store.
@param array $options
|
public function forget($key)
{
parent::forget($key);
// because the database store cannot store empty arrays, remove empty
// arrays to keep data consistent before and after saving
$segments = explode('.', $key);
array_pop($segments);
while ( ! empty($segments)) {
$segment = implode('.', $segments);
// non-empty array - exit out of the loop
if ($this->get($segment)) break;
// remove the empty array and move on to the next segment
$this->forget($segment);
array_pop($segments);
}
return $this;
}
|
Unset a key in the settings data.
@param string $key
@return self
|
protected function write(array $data)
{
$changes = $this->getChanges($data);
$this->syncUpdated($changes['updated']);
$this->syncInserted($changes['inserted']);
$this->syncDeleted($changes['deleted']);
}
|
Write the data into the store.
@param array $data
|
protected function newQuery($insert = false)
{
$query = $this->model->newQuery();
if ( ! $insert) {
foreach ($this->extraColumns as $key => $value) {
$query->where($key, '=', $value);
}
}
if ($this->hasQueryConstraint()) {
$callback = $this->queryConstraint;
$callback($query, $insert);
}
return $query;
}
|
Create a new query builder instance.
@param $insert bool
@return \Illuminate\Database\Eloquent\Builder
|
protected function prepareInsertData(array $data)
{
$dbData = [];
$extraColumns = $this->extraColumns ? $this->extraColumns : [];
foreach ($data as $key => $value) {
$dbData[] = array_merge($extraColumns, [
$this->keyColumn => $key,
$this->valueColumn => $value,
]);
}
return $dbData;
}
|
Transforms settings data into an array ready to be inserted into the database.
Call array_dot on a multidimensional array before passing it into this method!
@param array $data
@return array
|
private function getChanges(array $data)
{
$changes = [
'inserted' => Arr::dot($data),
'updated' => [],
'deleted' => [],
];
foreach ($this->newQuery()->pluck($this->keyColumn) as $key) {
if (Arr::has($changes['inserted'], $key))
$changes['updated'][$key] = $changes['inserted'][$key];
else
$changes['deleted'][] = $key;
Arr::forget($changes['inserted'], $key);
}
return $changes;
}
|
Get the changed settings data.
@param array $data
@return array
|
private function syncUpdated(array $updated)
{
foreach ($updated as $key => $value) {
$this->newQuery()
->where($this->keyColumn, '=', $key)
->update([$this->valueColumn => $value]);
}
}
|
Sync the updated records.
@param array $updated
|
private function syncInserted(array $inserted)
{
if ( ! empty($inserted)) {
$this->newQuery(true)->insert(
$this->prepareInsertData($inserted)
);
}
}
|
Sync the inserted records.
@param array $inserted
|
private function syncDeleted(array $deleted)
{
if ( ! empty($deleted)) {
$this->newQuery()->whereIn($this->keyColumn, $deleted)->delete();
}
}
|
Sync the deleted records.
@param array $deleted
|
public function category( $catIds, $listtype = 'default', $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
{
$this->controller->category( $catIds, $listtype, $level );
return $this;
}
|
Adds catalog IDs for filtering
@param array|string $catIds Catalog ID or list of IDs
@param string $listtype List type of the products referenced by the categories
@param integer $level Constant from \Aimeos\MW\Tree\Manager\Base if products in subcategories are matched too
@return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
@since 2019.04
|
public function has( $domain, $type = null, $refId = null )
{
$this->controller->has( $domain, $type, $refId );
return $this;
}
|
Adds a filter to return only items containing a reference to the given ID
@param string $domain Domain name of the referenced item, e.g. "attribute"
@param string|null $type Type code of the reference, e.g. "variant" or null for all types
@param string|null $refId ID of the referenced item of the given domain or null for all references
@return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
@since 2019.04
|
public function property( $type, $value = null, $langId = null )
{
$this->controller->property( $type, $value, $langId );
return $this;
}
|
Adds a filter to return only items containing the property
@param string $type Type code of the property, e.g. "isbn"
@param string|null $value Exact value of the property
@param string|null $langId ISO country code (en or en_US) or null if not language specific
@return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
@since 2019.04
|
public function code( $codes )
{
if( !empty( $codes ) ) {
$this->conditions[] = $this->filter->compare( '==', 'stock.productcode', $codes );
}
return $this;
}
|
Adds the SKUs of the products for filtering
@param array|string $codes Codes of the products
@return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
@since 2019.04
|
public function sort( $key = null )
{
$direction = '+';
if( $key != null && $key[0] === '-' )
{
$key = substr( $key, 1 );
$direction = '-';
}
switch( $key )
{
case null:
$this->filter->setSortations( [] );
break;
case 'stock':
$this->filter->setSortations( [
$this->filter->sort( $direction, 'stock.type' ),
$this->filter->sort( $direction, 'stock.stocklevel' )
] );
break;
default:
$this->filter->setSortations( [$this->filter->sort( $direction, $key )] );
}
return $this;
}
|
Sets the sorting of the result list
@param string|null $key Sorting of the result list like "stock.type", null for no sorting
@return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
@since 2019.04
|
public function type( $types )
{
if( !empty( $types ) ) {
$this->conditions[] = $this->filter->compare( '==', 'stock.type', $types );
}
return $this;
}
|
Adds stock types for filtering
@param array|string $types Stock type codes
@return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
@since 2019.04
|
public function get($key, $default = null)
{
$this->checkLoaded();
return Arr::get($this->data, $key, $default);
}
|
Get a specific key from the settings data.
@param string $key
@param mixed $default
@return mixed
|
public function forget($key)
{
$this->checkLoaded();
$this->unsaved = true;
Arr::forget($this->data, $key);
return $this;
}
|
Unset a key in the settings data.
@param string $key
@return self
|
public function save()
{
if ( ! $this->isSaved()) {
$this->write($this->data);
$this->unsaved = false;
}
return $this;
}
|
Save any changes done to the settings data.
@return self
|
protected function checkLoaded()
{
if ($this->isLoaded()) return;
$this->data = $this->read();
$this->loaded = true;
}
|
Check if the settings data has been loaded.
|
private function registerDriver($driver, array $configs)
{
$this->extend($driver, function () use ($configs) {
return new $configs['driver'](
$this->app, Arr::get($configs, 'options', [])
);
});
}
|
Register the driver.
@param string $driver
@param array $configs
|
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
{
/** @var \Symfony\Component\Validator\Constraints\AbstractComparison $constraint */
$constraintClass = get_class($constraint);
if ($constraintClass === LessThan::class) {
$rule = new ConstraintRule(
self::RULE_NAME,
$constraint->value - 1, // TODO support floats
new RuleMessage($constraint->message, array('{{ compared_value }}' => $constraint->value)),
$constraint->groups
);
} elseif ($constraintClass === LessThanOrEqual::class) {
$rule = new ConstraintRule(
self::RULE_NAME,
$constraint->value,
new RuleMessage($constraint->message, array('{{ compared_value }}' => $constraint->value)),
$constraint->groups
);
}
/** @var Range $constraint */
elseif ($constraintClass === Range::class && $constraint->max !== null) {
$rule = new ConstraintRule(
self::RULE_NAME,
$constraint->max,
new RuleMessage($constraint->maxMessage, array('{{ limit }}' => $constraint->max)),
$constraint->groups
);
} else {
throw new LogicException();
}
$collection->set(
self::RULE_NAME,
$rule
);
}
|
{@inheritdoc}
@param
|
protected function findConstraints(FormInterface $form)
{
$constraints = new ConstraintCollection();
// Find constraints configured with the form
$formConstraints = $form->getConfig()->getOption('constraints');
if (!empty($formConstraints)) {
if (is_array($formConstraints)) {
$constraints->addCollection(
new ConstraintCollection($formConstraints)
);
} else {
$constraints->add($formConstraints);
}
}
// Find constraints bound by data
if ($form->getConfig()->getMapped()) {
$constraints->addCollection(
$this->constraintFinder->find($form)
);
}
return $constraints;
}
|
Find all constraints for the given FormInterface.
@param FormInterface $form
@return ConstraintCollection
|
public static function loadFromResponse($networkId, $networkKey, array $response)
{
$subscription = new static($response['body']);
$subscription['id'] = $networkId;
$subscription['key'] = $networkKey;
return $subscription;
}
|
@param string $networkId
@param string $networkKey
@param array $response
@return \Acquia\Network\Subscription
|
public function up()
{
$this->createSchema(function(Blueprint $table) {
$table->unsignedInteger('user_id')->default(0);
$table->string('key');
$table->text('value');
$table->timestamps();
$table->unique(['user_id', 'key']);
});
}
|
{@inheritdoc}
|
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
{
if (!$this->supports($constraint, $form)) {
throw new LogicException();
}
/** @var Ip $constraint */
$ruleOptions = true;
switch ($constraint->version) {
case Ip::V4:
case Ip::V4_NO_PRIV:
case Ip::V4_NO_RES:
case Ip::V4_ONLY_PUBLIC:
if (!$this->useIpv4) {
return;
}
$ruleName = self::RULE_NAME_V4;
break;
case Ip::V6:
case Ip::V6_NO_PRIV:
case Ip::V6_NO_RES:
case Ip::V6_ONLY_PUBLIC:
if (!$this->useIpv6) {
return;
}
$ruleName = self::RULE_NAME_V6;
break;
case Ip::ALL:
case Ip::ALL_NO_PRIV:
case Ip::ALL_NO_RES:
case Ip::ALL_ONLY_PUBLIC:
if (!$this->useOrRule || !$this->useIpv6 || !$this->useIpv4) {
return;
}
$ruleName = self::RULE_NAME_OR;
$ruleOptions = array(self::RULE_NAME_V4 => true, self::RULE_NAME_V6 => true);
break;
default:
return;
}
$collection->set(
'ip',
new ConstraintRule(
$ruleName,
$ruleOptions,
new RuleMessage($constraint->message),
$constraint->groups
)
);
}
|
{@inheritdoc}
|
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
{
if (!$this->supports($constraint, $form)) {
throw new LogicException();
}
/** @var Luhn $constraint */
$collection->set(
self::RULE_NAME,
new ConstraintRule(
self::RULE_NAME,
true,
new RuleMessage($constraint->message),
$constraint->groups
)
);
}
|
{@inheritdoc}
|
public function get($name)
{
return isset($this->rules[$name]) ? $this->rules[$name] : null;
}
|
Gets a rule list by name.
@param string $name The form full_name
@return RuleCollection|null A array of Rule instances or null when not found
|
public function add( array $values )
{
$item = $this->item->fromArray( $values );
$addrItem = $item->getPaymentAddress();
if( $item->getLabel() === '' )
{
$label = $addrItem->getLastname();
if( ( $firstName = $addrItem->getFirstname() ) !== '' ) {
$label = $firstName . ' ' . $label;
}
if( ( $company = $addrItem->getCompany() ) !== '' ) {
$label .= ' (' . $company . ')';
}
$item = $item->setLabel( $label );
}
if( $item->getCode() === '' ) {
$item = $item->setCode( $addrItem->getEmail() );
}
$this->item = $item;
return $this;
}
|
Creates a new customer item object pre-filled with the given values but not yet stored
@param array $values Values added to the customer item (new or existing) like "customer.code"
@return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
@since 2019.04
|
public function addAddressItem( \Aimeos\MShop\Common\Item\Address\Iface $item, $idx = null )
{
$this->item = $this->item->addAddressItem( $item, $idx );
return $this;
}
|
Adds the given address item to the customer object (not yet stored)
@param \Aimeos\MShop\Common\Item\Address\Iface $item Address item to add
@param integer|null $idx Key in the list of address items or null to add the item at the end
@return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
@since 2019.04
|
public function addListItem( $domain, \Aimeos\MShop\Common\Item\Lists\Iface $item, \Aimeos\MShop\Common\Item\Iface $refItem = null )
{
$this->item = $this->item->addListItem( $domain, $item, $refItem );
return $this;
}
|
Adds the given list item to the customer object (not yet stored)
@param string $domain Domain name the referenced item belongs to
@param \Aimeos\MShop\Common\Item\Lists\Iface $item List item to add
@param \Aimeos\MShop\Common\Item\Iface|null $refItem Referenced item to add or null if list item contains refid value
@return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
@since 2019.04
|
public function createAddressItem( array $values = [] )
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'customer/address' );
return $manager->createItem()->fromArray( $values );
}
|
Creates a new address item object pre-filled with the given values
@return \Aimeos\MShop\Customer\Item\Address\Iface Address item
@since 2019.04
|
public function delete()
{
if( $this->item && $this->item->getId() ) {
\Aimeos\MShop::create( $this->getContext(), 'customer' )->deleteItem( $this->item->getId() );
}
return $this;
}
|
Deletes a customer item that belongs to the current authenticated user
@return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items
@since 2019.04
|
public function deletePropertyItem( \Aimeos\MShop\Common\Item\Property\Iface $item )
{
$this->item = $this->item->deletePropertyItem( $item );
return $this;
}
|
Removes the given property item from the customer object (not yet stored)
@param \Aimeos\MShop\Common\Item\Property\Iface $item Property item to remove
@return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
|
public function store()
{
( $id = $this->item->getId() ) !== null ? $this->checkId( $id ) : $this->checkLimit();
$context = $this->getContext();
if( $id === null )
{
$msg = $this->item->toArray();
$msg['customer.password'] = null;
// Show only generated passwords in account creation e-mails
if( $this->item->getPassword() === '' ) {
$msg['customer.password'] = substr( sha1( microtime( true ) . getmypid() . rand() ), -8 );
}
$context->getMessageQueue( 'mq-email', 'customer/email/account' )->add( json_encode( $msg ) );
}
$this->item = $this->manager->saveItem( $this->item );
return $this;
}
|
Adds or updates a modified customer item in the storage
@return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
@since 2019.04
|
public function uses( array $domains )
{
$this->domains = $domains;
if( ( $id = $this->getContext()->getUserId() ) !== null ) {
$this->item = $this->manager->getItem( $id, $domains, true );
}
return $this;
}
|
Sets the domains that will be used when working with the customer item
@param array $domains Domain names of the referenced items that should be fetched too
@return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
@since 2019.04
|
protected function checkId( $id )
{
if( $id != $this->getContext()->getUserId() )
{
$msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id );
throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg );
}
return $id;
}
|
Checks if the current user is allowed to retrieve the customer data for the given ID
@param string $id Unique customer ID
@return string Unique customer ID
@throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed
|
public static function factory($config = array())
{
$defaults = array(
'base_url' => 'https://rpc.acquia.com',
'server_address' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '',
'http_host' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '',
'https' => false,
'network_id' => '',
'network_key' => '',
);
// Instantiate the Acquia Search plugin.
$config = Collection::fromConfig($config, $defaults);
return new static(
$config->get('base_url'),
$config->get('network_id'),
$config->get('network_key'),
$config
);
}
|
{@inheritdoc}
@return \Acquia\Network\AcquiaNetworkClient
|
protected function defaultRequestParams()
{
$params = array(
'authenticator' => $this->buildAuthenticator(),
'ssl' => $this->https === true ? 1 : 0,
'ip' => $this->serverAddress,
'host' => $this->httpHost,
);
return $params;
}
|
Returns default paramaters for request. Not every call requires these.
@return array
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.