code
stringlengths 52
7.75k
| docs
stringlengths 1
5.85k
|
---|---|
protected function call($method, array $params)
{
$uri = $this->getConfig('base_url') . '/xmlrpc.php';
$bridge = new \fXmlRpc\Transport\GuzzleBridge($this);
$client = new \fXmlRpc\Client($uri, $bridge);
// We have to nest the params in an array otherwise we get a "Wrong
// number of method parameters" error.
return $client->call($method, array($params));
}
|
@param string $method
@param array $params
@return array
@throws \fXmlRpc\Exception\ResponseException
|
public function validateCredentials(&$errstr = null)
{
try {
$errstr = '';
$params = $this->defaultRequestParams();
$this->call('acquia.agent.validate', $params);
return true;
} catch (ResponseException $e) {
$errstr = $e->getMessage();
return false;
}
}
|
@param string &$errstr
@return bool
|
public function getSubscriptionName()
{
if (empty($this->networkId)) {
throw new \UnexpectedValueException('Acquia Network identifier required');
}
$params = $this->defaultRequestParams();
$params['body'] = array(
'identifier' => $this->networkId,
);
$response = $this->call('acquia.agent.subscription.name', $params);
if (!isset($response['body']['subscription']['site_name'])) {
throw new \OutOfBoundsException('Invalid response returned from server.');
}
return $response['body']['subscription']['site_name'];
}
|
@return string
@throws \UnexpectedValueException
@throws \OutOfBoundsException
|
public function getCommunicationSettings($email)
{
// Build a light authenticator.
$signature = new Signature('x');
$signature->getNoncer()->setLength(self::NONCE_LENGTH);
$authentiator = array(
'time' => $signature->getRequestTime(),
'hash' => $signature->generate(),
'nonce' => $signature->getNonce(),
);
$params = array(
'authenticator' => $authentiator,
'body' => array('email' => $email),
);
return $this->call('acquia.agent.communication.settings', $params);
}
|
@param string $email
@return array
@throws \fXmlRpc\Exception\ResponseException
|
public function getSubscriptionCredentials($email, $password)
{
// Build a light authenticator.
$signature = new Signature($password);
$signature->getNoncer()->setLength(self::NONCE_LENGTH);
$authentiator = array(
'time' => $signature->getRequestTime(),
'hash' => $signature->generate(),
'nonce' => $signature->getNonce(),
);
$params = array(
'authenticator' => $authentiator,
'body' => array('email' => $email),
);
$response = $this->call('acquia.agent.subscription.credentials', $params);
// @todo catch error and/or check response is_error
// @todo set this key/id
return $response;
}
|
@param $email
@param $password
@throws \fXmlRpc\Exception\ResponseException
|
protected function buildAuthenticator($params = array())
{
$signature = new Signature($this->networkKey);
$signature->getNoncer()->setLength(self::NONCE_LENGTH);
$authenticator = array(
'identifier' => $this->networkId,
'time' => $signature->getRequestTime(),
'hash' => $signature->generate($params),
'nonce' => $signature->getNonce(),
);
return $authenticator;
}
|
/*
@params array
Parameters to have signed.
@return string
|
public function getSubscription(array $options = array())
{
$params = $this->defaultRequestParams();
$params['body'] = $options;
$response = $this->call('acquia.agent.subscription', $params);
return Subscription::loadFromResponse($this->networkId, $this->networkKey, $response);
}
|
@param array $options
- search_version: An array of search module versions keyed by name.
- no_heartbeat: Pass 1 to not send a heartbeat.
@return \Acquia\Network\Subscription
|
public function checkSubscription($services = 0)
{
$options = array();
if ($services & Services::ACQUIA_SEARCH) {
$options = array(
'search_version' => array('acquia/acquia-search-sdk' => Version::RELEASE)
);
}
return $this->getSubscription($options);
}
|
@param int $services
@return \Acquia\Network\Subscription
|
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
{
$constraintClass = get_class($constraint);
/** @var \Symfony\Component\Validator\Constraints\AbstractComparison $constraint */
if ($constraintClass === GreaterThan::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 === GreaterThanOrEqual::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->min !== null) {
$rule = new ConstraintRule(
self::RULE_NAME,
$constraint->min,
new RuleMessage($constraint->minMessage, array('{{ limit }}' => $constraint->min)),
$constraint->groups
);
} else {
throw new LogicException();
}
$collection->set(
self::RULE_NAME,
$rule
);
}
|
{@inheritdoc}
@param
|
public function aggregate( $key )
{
$this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) );
return $this->manager->aggregate( $this->filter, $key );
}
|
Returns the aggregated count of products for the given key.
@param string $key Search key to aggregate for, e.g. "index.attribute.id"
@return array Associative list of key values as key and the product count for this key as value
@since 2019.04
|
public function allOf( $attrIds )
{
if( !empty( $attrIds ) && ( $ids = array_unique( $this->validateIds( (array) $attrIds ) ) ) !== [] )
{
$func = $this->filter->createFunction( 'index.attribute:allof', [$ids] );
$this->conditions[] = $this->filter->compare( '!=', $func, null );
}
return $this;
}
|
Adds attribute IDs for filtering where products must reference all IDs
@param array|string $attrIds Attribute ID or list of IDs
@return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
@since 2019.04
|
public function category( $catIds, $listtype = 'default', $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
{
if( !empty( $catIds ) && ( $ids = $this->validateIds( (array) $catIds ) ) !== [] )
{
if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
{
$list = [];
$cntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'catalog' );
foreach( $ids as $catId ) {
$list += $cntl->root( $catId )->getTree( $level )->toList();
}
$ids = array_keys( $list );
}
$func = $this->filter->createFunction( 'index.catalog:position', [$listtype, $ids] );
$this->conditions[] = $this->filter->compare( '==', 'index.catalog.id', $ids );
$this->conditions[] = $this->filter->compare( '>=', $func, 0 );
$func = $this->filter->createFunction( 'sort:index.catalog:position', [$listtype, $ids] );
$this->sort = $this->filter->sort( '+', $func );
}
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 find( $code )
{
return $this->manager->findItem( $code, $this->domains, 'product', null, true );
}
|
Returns the product for the given product code
@param string $code Unique product code
@return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
@since 2019.04
|
public function has( $domain, $type = null, $refId = null )
{
$params = [$domain];
!$type ?: $params[] = $type;
!$refId ?: $params[] = $refId;
$func = $this->filter->createFunction( 'product:has', $params );
$this->conditions[] = $this->filter->compare( '!=', $func, null );
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 oneOf( $attrIds )
{
$attrIds = (array) $attrIds;
foreach( $attrIds as $key => $entry )
{
if( is_array( $entry ) && ( $ids = array_unique( $this->validateIds( $entry ) ) ) !== [] )
{
$func = $this->filter->createFunction( 'index.attribute:oneof', [$ids] );
$this->conditions[] = $this->filter->compare( '!=', $func, null );
unset( $attrIds[$key] );
}
}
if( ( $ids = array_unique( $this->validateIds( $attrIds ) ) ) !== [] )
{
$func = $this->filter->createFunction( 'index.attribute:oneof', [$ids] );
$this->conditions[] = $this->filter->compare( '!=', $func, null );
}
return $this;
}
|
Adds attribute IDs for filtering where products must reference at least one ID
If an array of ID lists is given, each ID list is added separately as condition.
@param array|string $attrIds Attribute ID, list of IDs or array of lists with IDs
@return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
@since 2019.04
|
public function product( $prodIds )
{
if( !empty( $prodIds ) && ( $ids = array_unique( $this->validateIds( (array) $prodIds ) ) ) !== [] ) {
$this->conditions[] = $this->filter->compare( '==', 'product.id', $ids );
}
return $this;
}
|
Adds product IDs for filtering
@param array|string $prodIds Product ID or list of IDs
@return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
@since 2019.04
|
public function resolve( $name )
{
$langid = $this->getContext()->getLocale()->getLanguageId();
$search = $this->manager->createSearch();
$func = $search->createFunction( 'index.text:url', [$langid] );
$search->setConditions( $search->compare( '==', $func, $name ) );
$items = $this->manager->searchItems( $search, $this->domains );
if( ( $item = reset( $items ) ) !== false ) {
return $item;
}
throw new \Aimeos\Controller\Frontend\Product\Exception( sprintf( 'Unable to find product "%1$s"', $name ) );
}
|
Returns the product for the given product URL name
@param string $name Product URL name
@return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
@since 2019.04
|
public function search( &$total = null )
{
$this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) );
return $this->manager->searchItems( $this->filter, $this->domains, $total );
}
|
Returns the products filtered by the previously assigned conditions
@param integer &$total Parameter where the total number of found products will be stored in
@return \Aimeos\MShop\Product\Item\Iface[] Ordered list of product items
@since 2019.04
|
public function supplier( $supIds, $listtype = 'default' )
{
if( !empty( $supIds ) && ( $ids = array_unique( $this->validateIds( (array) $supIds ) ) ) !== [] )
{
$func = $this->filter->createFunction( 'index.supplier:position', [$listtype, $ids] );
$this->conditions[] = $this->filter->compare( '==', 'index.supplier.id', $ids );
$this->conditions[] = $this->filter->compare( '>=', $func, 0 );
$func = $this->filter->createFunction( 'sort:index.supplier:position', [$listtype, $ids] );
$this->sort = $this->filter->sort( '+', $func );
}
return $this;
}
|
Adds supplier IDs for filtering
@param array|string $supIds Supplier ID or list of IDs
@param string $listtype List type of the products referenced by the suppliers
@return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
@since 2019.04
|
public function text( $text )
{
if( !empty( $text ) )
{
$langid = $this->getContext()->getLocale()->getLanguageId();
$func = $this->filter->createFunction( 'index.text:relevance', [$langid, $text] );
$this->conditions[] = $this->filter->compare( '>', $func, 0 );
}
return $this;
}
|
Adds input string for full text search
@param string|null $text User input for full text search
@return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
@since 2019.04
|
protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
{
if( $item->getStatus() < 1 ) {
return [];
}
$list = [ $item->getId() ];
foreach( $item->getChildren() as $child ) {
$list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
}
return $list;
}
|
Returns the list of catalog IDs for the given catalog tree
@param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
@return array List of catalog IDs
|
protected function validateIds( array $ids )
{
$list = [];
foreach( $ids as $id )
{
if( $id != '' && preg_match( '/^[A-Za-z0-9\-\_]+$/', $id ) === 1 ) {
$list[] = (string) $id;
}
}
return $list;
}
|
Validates the given IDs as integers
@param array $ids List of IDs to validate
@return array List of validated IDs
|
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
{
if (!$this->supports($constraint, $form)) {
throw new LogicException();
}
$boolType = $constraint instanceof IsTrue;
// If the isTrue is applied and it is a checkbox then just make it required
if ($boolType && $form->getConfig()->getType()->getInnerType() instanceof CheckboxType) {
$collection->set(
RequiredRule::RULE_NAME,
new ConstraintRule(
RequiredRule::RULE_NAME,
true,
new RuleMessage($constraint->message),
$constraint->groups
)
);
return;
}
// A additional method is used to skip if not found
if (!$this->useAdditional) {
return;
}
/** @var IsTrue|IsFalse $constraint */
$collection->set(
'equals',
new ConstraintRule(
'equals',
$boolType ? '1' : '0',
new RuleMessage($constraint->message),
$constraint->groups
)
);
}
|
{@inheritdoc}
|
public function jsonEncode($data): string
{
try {
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
} catch (JsonException $exception) {
throw new Exception('Error while encoding to JSON', 0, $exception);
}
}
|
{@inheritdoc}
|
public function jsonDecode(string $json)
{
try {
return json_decode($json, true, self::JSON_DEFAULT_DEPTH, JSON_THROW_ON_ERROR);
} catch (JsonException $exception) {
throw new Exception('Error while decoding to JSON', 0, $exception);
}
}
|
{@inheritdoc}
|
public function base64UrlDecode(string $data): string
{
$remainder = strlen($data) % self::BASE64_PADDING_LENGTH;
if ($remainder !== 0) {
$data .= str_repeat('=', self::BASE64_PADDING_LENGTH - $remainder);
}
$decodedContent = base64_decode(strtr($data, '-_', '+/'), true);
if (! is_string($decodedContent)) {
throw new Exception('Error while decoding from Base64: invalid characters used');
}
return $decodedContent;
}
|
{@inheritdoc}
|
public static function assertNumCalls(
FBMock_Mock $mock,
$method_name,
$expected_num_calls,
$msg = '') {
FBMock_Utils::assertString($method_name);
FBMock_Utils::assertInt($expected_num_calls);
$call_count = count($mock->mockGetCalls($method_name));
PHPUnit\Framework\TestCase::assertEquals(
$expected_num_calls,
$call_count,
$msg ?: "$method_name called wrong number of times"
);
}
|
Assert that the method was called a certain number of times on a mock
@param $mock a mock object
@param $method_name name of method to check
@param $expected_num_calls expected number of calls
@param $msg message for assert (optional)
|
public static function assertCalledOnce(
FBMock_Mock $mock,
$method_name,
$args=null,
$msg='') {
FBMock_Utils::assertString($method_name);
self::assertNumCalls($mock, $method_name, 1, $msg);
if ($args !== null) {
PHPUnit\Framework\TestCase::assertEquals(
$args,
$mock->mockGetCalls($method_name)[0],
$msg ?: "$method_name args are not equal"
);
}
}
|
Assert that the method was called once. If $args is given, check that it
matches the args $method_name was called with.
@param $mock a mock object
@param $method_name name of method to check
@param $args expected arguments (optional)
@param $msg message for assert (optional)
|
public static function assertNotCalled(
FBMock_Mock $mock,
$method_name,
$msg='') {
FBMock_Utils::assertString($method_name);
self::assertNumCalls($mock, $method_name, 0, $msg);
}
|
Assert that the method was not called.
@param $mock a mock object
@param $method_name name of method to check
@param $msg message for assert (optional)
|
public static function assertCalls(
FBMock_Mock $mock,
$method_name
/* array $expected_first_call, array $expected_second_call, $msg = ''*/) {
FBMock_Utils::assertString($method_name);
$args = func_get_args();
$msg = '';
if (is_string(end($args))) {
$msg = array_pop($args);
}
$expected_calls = array_slice($args, 2);
self::assertNumCalls($mock, $method_name, count($expected_calls), $msg);
$actual_calls = $mock->mockGetCalls($method_name);
foreach ($expected_calls as $i => $call) {
PHPUnit\Framework\TestCase::assertEquals(
$call,
$actual_calls[$i],
$msg ?: "Call $i for method $method_name did not match expected call"
);
}
}
|
Assert that the method calls match the array of calls.
Example usage:
// Code under test calls method
$mock->testMethod(1,2,3);
$mock->testMethod('a', 'b', 'c');
// Test asserts calls
self::assertCalls(
$mock,
'testMethod',
array(1,2,3),
array('a', 'b', 'c')
);
@param $mock a mock object
@param $method_name name of method to check
@param ... arrays of expected arguments for each call
@param $msg message for assert (optional)
|
public function add( $baseId, array $values = [] )
{
$this->item = $this->item->fromArray( $values )->setBaseId( $baseId );
return $this;
}
|
Adds the values to the order object (not yet stored)
@param string $baseId ID of the stored basket
@param array $values Values added to the order item (new or existing) like "order.type"
@return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface
@since 2019.04
|
public function save( \Aimeos\MShop\Order\Item\Iface $orderItem )
{
return $this->manager->saveItem( $orderItem );
}
|
Updates the given order item in the storage
@param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object
@return \Aimeos\MShop\Order\Item\Iface $orderItem Saved order item object
@since 2019.04
|
public function store()
{
$this->checkLimit( $this->item->getBaseId() );
$cntl = \Aimeos\Controller\Common\Order\Factory::create( $this->getContext() );
$this->item = $this->manager->saveItem( $this->item );
return $cntl->block( $this->item );
}
|
Saves the modified order item in the storage and blocks the stock and coupon codes
@return \Aimeos\MShop\Order\Item\Iface New or updated order item object
@since 2019.04
|
protected function checkLimit( $baseId )
{
/** controller/frontend/order/limit-seconds
* Order limitation time frame in seconds
*
* Creating new orders is limited to avoid abuse and mitigate denial of
* service attacks. Within the configured time frame, only one order
* item can be created per order base item. All orders for the order
* base item within the last X seconds are counted. If there's already
* one available, an error message will be shown to the user instead of
* creating the new order item.
*
* @param integer Number of seconds to check order items within
* @since 2017.05
* @category Developer
* @see controller/frontend/basket/limit-count
* @see controller/frontend/basket/limit-seconds
*/
$seconds = $this->getContext()->getConfig()->get( 'controller/frontend/order/limit-seconds', 300 );
$search = $this->manager->createSearch()->setSlice( 0, 0 );
$search->setConditions( $search->combine( '&&', [
$search->compare( '==', 'order.baseid', $baseId ),
$search->compare( '>=', 'order.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ),
] ) );
$total = 0;
$this->manager->searchItems( $search, [], $total );
if( $total > 0 ) {
throw new \Aimeos\Controller\Frontend\Order\Exception( sprintf( 'The order has already been created' ) );
}
return $this;
}
|
Checks if more orders than allowed have been created by the user
@param string $baseId Unique ID of the order base item (basket)
@return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface
@throws \Aimeos\Controller\Frontend\Order\Exception If limit is exceeded
|
public function mockReturn(/* ... */) {
$args = $this->mockAssertMultiArgs(func_get_args(), __METHOD__);
if (count($args) == 1) {
foreach ($args[0] as $method_name => $value) {
FBMock_Utils::assertString($method_name);
$this->__mockReturn($method_name, $value);
}
return $this;
}
return $this->__mockReturn($args[0], $args[1]);
}
|
implements Mock
|
public function camo($url)
{
return $this->formatter->formatCamoUrl(
$this->domain,
$this->getDigest($url),
$url
);
}
|
Camoflauge all urls
@param $url
@return string
|
public function camoHttpOnly($url)
{
$parsed = parse_url($url);
if ( $parsed['scheme'] == 'https' ) {
return $url;
}
return $this->camo($url);
}
|
Camoflauge only the urls that are not currently https
@param $url
@return mixed
|
protected static function addDecorators( \Aimeos\MShop\Context\Item\Iface $context,
\Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix )
{
foreach( $decorators as $name )
{
if( ctype_alnum( $name ) === false )
{
$classname = is_string( $name ) ? $classprefix . $name : '<not a string>';
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
}
$classname = $classprefix . $name;
if( class_exists( $classname ) === false ) {
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) );
}
$controller = new $classname( $controller, $context );
\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\Iface', $controller );
}
return $controller;
}
|
Adds the decorators to the controller object.
@param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects
@param \Aimeos\Controller\Frontend\Common\Iface $controller Controller object
@param array $decorators List of decorator names that should be wrapped around the controller object
@param string $classprefix Decorator class prefix, e.g. "\Aimeos\Controller\Frontend\Basket\Decorator\"
@return \Aimeos\Controller\Frontend\Common\Iface Controller object
|
protected static function createController( \Aimeos\MShop\Context\Item\Iface $context, $classname, $interface )
{
if( isset( self::$objects[$classname] ) ) {
return self::$objects[$classname];
}
if( class_exists( $classname ) === false ) {
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) );
}
$controller = new $classname( $context );
\Aimeos\MW\Common\Base::checkClass( $interface, $controller );
return $controller;
}
|
Creates a controller object.
@param \Aimeos\MShop\Context\Item\Iface $context Context instance with necessary objects
@param string $classname Name of the controller class
@param string $interface Name of the controller interface
@return \Aimeos\Controller\Frontend\Common\Iface Controller object
|
public function attribute( $attrIds )
{
if( !empty( $attrIds ) ) {
$this->conditions[] = $this->filter->compare( '==', 'attribute.id', $attrIds );
}
return $this;
}
|
Adds attribute IDs for filtering
@param array|string $attrIds Attribute ID or list of IDs
@return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface
@since 2019.04
|
public function find( $code, $type )
{
return $this->manager->findItem( $code, $this->domains, $this->domain, $type, true );
}
|
Returns the attribute for the given attribute code
@param string $code Unique attribute code
@param string $type Type assigned to the attribute
@return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items
@since 2019.04
|
public function property( $type, $value = null, $langId = null )
{
$func = $this->filter->createFunction( 'attribute:prop', [$type, $langId, $value] );
$this->conditions[] = $this->filter->compare( '!=', $func, null );
return $this;
}
|
Adds a filter to return only items containing the property
@param string $type Type code of the property, e.g. "htmlcolor"
@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\Attribute\Iface Attribute controller for fluent interface
@since 2019.04
|
public function search( &$total = null )
{
$expr = array_merge( $this->conditions, [$this->filter->compare( '==', 'attribute.domain', $this->domain )] );
$this->filter->setConditions( $this->filter->combine( '&&', $expr ) );
return $this->manager->searchItems( $this->filter, $this->domains, $total );
}
|
Returns the attributes filtered by the previously assigned conditions
@param integer &$total Parameter where the total number of found attributes will be stored in
@return \Aimeos\MShop\Attribute\Item\Iface[] Ordered list of attribute items
@since 2019.04
|
public function type( $codes )
{
if( !empty( $codes ) ) {
$this->conditions[] = $this->filter->compare( '==', 'attribute.type', $codes );
}
return $this;
}
|
Adds attribute types for filtering
@param array|string $codes Attribute ID or list of IDs
@return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface
@since 2019.04
|
public function getIterator()
{
$array = $this->getArrayCopy();
// Is the collection nested in the array?
if (isset($this->collectionProperty)) {
// Locate the collection in the response.
$collectionFound = false;
$property = NULL;
foreach ((array) $this->collectionProperty as $property) {
if (isset($array[$property])) {
$collectionFound = true;
break;
}
}
if (!$collectionFound) {
throw new \OutOfBoundsException('Collection not found in response');
}
$array = $array[$property];
}
// Build the collection.
$collection = array();
foreach ($array as $item) {
$element = new $this->elementClass($item);
$collection[(string) $element] = $element;
}
return new \ArrayObject($collection);
}
|
Keys the array of objects by their identifier, constructs and returns and
array object.
When the object is cast to a string, its unique identifier is returned.
@return \ArrayObject
@throws \OutOfBoundsException
@see \Acquia\Rest\Element::__toString()
|
public function add( array $values )
{
$this->baskets[$this->type] = $this->get()->fromArray( $values );
return $this;
}
|
Adds values like comments to the basket
@param array $values Order base values like comment
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
|
public function clear()
{
$this->baskets[$this->type] = $this->manager->createItem();
$this->manager->setSession( $this->baskets[$this->type], $this->type );
return $this;
}
|
Empties the basket and removing all products, addresses, services, etc.
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
|
public function get()
{
if( !isset( $this->baskets[$this->type] ) )
{
$this->baskets[$this->type] = $this->manager->getSession( $this->type );
$this->checkLocale( $this->baskets[$this->type]->getLocale(), $this->type );
}
return $this->baskets[$this->type];
}
|
Returns the basket object.
@return \Aimeos\MShop\Order\Item\Base\Iface Basket holding products, addresses and delivery/payment options
|
public function save()
{
if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) {
$this->manager->setSession( $this->baskets[$this->type], $this->type );
}
return $this;
}
|
Explicitely persists the basket content
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
|
public function load( $id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true )
{
return $this->manager->load( $id, $parts, false, $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 deleteProduct( $position )
{
$product = $this->get()->getProduct( $position );
if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE )
{
$msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually' );
throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) );
}
$this->baskets[$this->type] = $this->get()->deleteProduct( $position );
return $this->save();
}
|
Deletes a product item from the basket.
@param integer $position Position number (key) of the order product item
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
|
public function updateProduct( $position, $quantity )
{
$product = $this->get()->getProduct( $position );
if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE )
{
$msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be changed' );
throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) );
}
$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );
$productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ), true );
$price = $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity );
$product = $product->setQuantity( $quantity )->setPrice( $price );
$this->baskets[$this->type] = $this->get()->addProduct( $product, $position );
return $this->save();
}
|
Edits the quantity of a product item in the basket.
@param integer $position Position number (key) of the order product item
@param integer $quantity New quantiy of the product item
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
|
public function addCoupon( $code )
{
$context = $this->getContext();
/** controller/frontend/basket/standard/coupon/allowed
* Number of coupon codes a customer is allowed to enter
*
* This configuration option enables shop owners to limit the number of coupon
* codes that can be added by a customer to his current basket. By default, only
* one coupon code is allowed per order.
*
* Coupon codes are valid until a payed order is placed by the customer. The
* "count" of the codes is decreased afterwards. If codes are not personalized
* the codes can be reused in the next order until their "count" reaches zero.
*
* @param integer Positive number of coupon codes including zero
* @since 2017.08
* @category User
* @category Developer
*/
$allowed = $context->getConfig()->get( 'controller/frontend/basket/standard/coupon/allowed', 1 );
if( $allowed <= count( $this->get()->getCoupons() ) )
{
$msg = $context->getI18n()->dt( 'controller/frontend', 'Number of coupon codes exceeds the limit' );
throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
}
$this->baskets[$this->type] = $this->get()->addCoupon( $code );
return $this->save();
}
|
Adds the given coupon code and updates the basket.
@param string $code Coupon code entered by the user
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
@throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed
|
public function deleteCoupon( $code )
{
$this->baskets[$this->type] = $this->get()->deleteCoupon( $code );
return $this->save();
}
|
Removes the given coupon code and its effects from the basket.
@param string $code Coupon code entered by the user
@return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object for fluent interface
@throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid
|
public function addAddress( $type, array $values = [], $position = null )
{
foreach( $values as $key => $value ) {
$values[$key] = strip_tags( $value ); // prevent XSS
}
$context = $this->getContext();
$address = \Aimeos\MShop::create( $context, 'order/base/address' )->createItem()->fromArray( $values );
$this->baskets[$this->type] = $this->get()->addAddress( $address, $type, $position );
return $this->save();
}
|
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->baskets[$this->type] = $this->get()->deleteAddress( $type, $position );
return $this->save();
}
|
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 deleteService( $type, $position = null )
{
$this->baskets[$this->type] = $this->get()->deleteService( $type, $position );
return $this->save();
}
|
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 function dsn()
{
// @see https://github.com/acquia/acquia-sdk-php/issues/27
if (!isset($this['name'])) {
throw new \OutOfBoundsException('Malformed response: expecting "name" property');
}
if (!isset($this['host'])) {
throw new \OutOfBoundsException('Malformed response: expecting "host" property');
}
if (!isset($this['port'])) {
throw new \OutOfBoundsException('Malformed response: expecting "port" property');
}
return 'mysql:dbname=' . $this['name'] . ';host=' . $this['host'] . ';port=' . $this['port'];
}
|
Returns the DSN for the active host.
@return string
@throws \OutOfBoundsException
|
public function getPath( $id )
{
$list = $this->manager->getPath( $id, $this->domains );
if( $this->root )
{
foreach( $list as $key => $item )
{
if( $key == $this->root ) {
break;
}
unset( $list[$key] );
}
}
return $list;
}
|
Returns the list of categories up to the root node including the node given by its ID
@param integer $id Current category ID
@return \Aimeos\MShop\Catalog\Item\Iface[] Associative list of categories
@since 2017.03
|
public function getTree( $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE )
{
$this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) );
return $this->manager->getTree( $this->root, $this->domains, $level, $this->filter );
}
|
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 static function encode($data, $prettyPrint = true)
{
$options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
$useNative = self::$useNativePrettyPrint && defined('JSON_PRETTY_PRINT') && defined('JSON_UNESCAPED_SLASHES');
if ($prettyPrint && $useNative) {
$options = $options | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;
}
$json = json_encode($data, $options);
if ($prettyPrint && !$useNative) {
$json = self::prettyPrint($json);
}
return $json;
}
|
@param mixed $data
@param bool $prettyPrint
@return string
|
protected static function prettyPrint($json)
{
$result = '';
$pos = 0;
$indentation = ' ';
$newline = "\n";
$previousChar = '';
$outOfQuotes = true;
// Unescape slashes.
if (strpos($json, '/')) {
$json = preg_replace('#\134{1}/#', '/', $json);
}
$stringLength = strlen($json);
for ($i = 0; $i <= $stringLength; $i++) {
// Grab the next character in the string.
$char = substr($json, $i, 1);
if (':' == $previousChar && $outOfQuotes) {
$result .= ' ';
}
// Are we inside a quoted string?
if ('"' == $char && $previousChar != '\\') {
$outOfQuotes = !$outOfQuotes;
// If this character is the end of an element,
// output a new line and indent the next line.
} elseif (('}' == $char || ']' == $char) && $outOfQuotes) {
$result .= $newline;
$pos --;
for ($j = 0; $j < $pos; $j++) {
$result .= $indentation;
}
}
// Add the character to the result string.
$result .= $char;
// If the last character was the beginning of an element,
// output a new line and indent the next line.
if ((',' == $char || '{' == $char || '[' == $char) && $outOfQuotes) {
$result .= $newline;
if ('{' == $char || '[' == $char) {
$pos ++;
}
for ($j = 0; $j < $pos; $j++) {
$result .= $indentation;
}
}
$previousChar = $char;
}
return $result;
}
|
Indents a flat JSON string to make it more human-readable.
The JSON_PRETTY_PRINT and JSON_UNESCAPED_SLASHES options are not
available until PHP 5.4.
@param string $json
@return string
|
public static function parseFile($filepath)
{
if (!is_file($filepath)) {
throw new \RuntimeException('File not found: ' . $filepath);
}
if (!$filedata = static::readFiledata($filepath)) {
throw new \RuntimeException('Error reading file: ' . $filepath);
}
if (!$json = self::decode($filedata)) {
throw new \RuntimeException('Error parsing json: ' . $filepath);
}
return $json;
}
|
Parses a file into a PHP array.
@param string $filepath
@throws \RuntimeException
|
public function credentials($dbName)
{
$creds = $this->cloudEnvironment->serviceCredentials();
if (!isset($creds['databases'][$dbName])) {
throw new \OutOfBoundsException('Invalid database: ' . $dbName);
}
$database = $creds['databases'][$dbName];
$host = $this->getCurrentHost($database['db_cluster_id']);
$database['host'] = ($host) ?: key($database['db_url_ha']);
return new DatabaseCredentials($database);
}
|
{@inheritDoc}
|
public function getCurrentHost($clusterId)
{
try {
$resolver = $this->getResolver();
$response = $resolver->query('cluster-' . $clusterId . '.mysql', 'CNAME');
return $response->answer[0]->cname;
} catch (\Net_DNS2_Exception $e) {
return '';
}
}
|
@param in $clusterId
@return string
|
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
{
if (!$this->supports($constraint, $form)) {
throw new LogicException();
}
$message = null;
if ($constraint instanceof Range) {
$message = new RuleMessage($constraint->invalidMessage);
} elseif ($constraint instanceof Type) {
$message = new RuleMessage($constraint->message, array('{{ type }}' => $constraint->type));
}
$collection->set(
self::RULE_NAME,
new ConstraintRule(
self::RULE_NAME,
true,
$message,
$constraint->groups
)
);
}
|
{@inheritdoc}
|
public function load(array $config, ContainerBuilder $container)
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), $config);
$this->configureForm($container, $config, $loader);
$this->configureFormAdditionals($container, $config, $loader);
$this->configureTwig($config, $loader);
}
|
{@inheritdoc}
|
public function add($view, RuleCollection $collection)
{
$name = FormHelper::getFormName($view);
if (isset($this->rules[$name])) {
$this->rules[$name]->addCollection($collection);
} else {
$this->rules[$name] = $collection;
}
}
|
Adds a rule collection.
@param string|FormView $view The form full_name or view instance
@param RuleCollection $collection A RuleCollection instance
|
public function getConfigFilename($group)
{
$conf_files = $this->config->get('conf_files');
if (!isset($conf_files[$group])) {
$filename = $this->config['conf_dir'] . '/' . $group . '.json';
$conf_files[$group] = $filename;
}
$this->config->set('conf_files', $conf_files);
return $conf_files[$group];
}
|
@param string $group
@return string
|
public function hasConfigFile($name)
{
$filename = $this->getConfigFilename($name);
return is_file($filename) && is_readable($filename);
}
|
@param string $name
@return boolean
|
public function load($group)
{
$confg = $this->hasConfigFile($group) ? $this->getConfigFilename($group) : array();
return ServiceBuilder::factory($confg);
}
|
@param string $group
@return \Guzzle\Service\Builder\ServiceBuilder
|
public function offsetGet($group)
{
if (!isset($this[$group])) {
// Load builder from file or instantiate an empty one.
if ($this->hasConfigFile($group)) {
$this[$group] = $this->load($group);
} else {
$this[$group] = ServiceBuilder::factory(array());
}
// Initialize the "removed" flag.
$this->removed[$group] = array();
}
return parent::offsetGet($group);
}
|
@param string $group
@return \Guzzle\Service\Builder\ServiceBuilder
|
public function setBuilder($group, ServiceBuilder $builder)
{
$this[$group] = $builder;
$this->removed[$group] = array();
return $this;
}
|
@param string $group
@param \Guzzle\Service\Builder\ServiceBuilder $builder
@return \Acquia\Rest\ServiceManager
|
public function setClient($group, $name, Client $client)
{
// Must also be service manager aware.
if (!$client instanceof ServiceManagerAware) {
throw new \UnexpectedValueException('Client must implement Acquia\Rest\ServiceManagerAware');
}
$builder = $this[$group];
// Set the client in the service builder.
$builder[$name] = $client;
// This looks funky, but it is actually not overwriting the value we
// just set. This snippet adds the builder config so that saving the
// service will add this client as a service in the JSON file.
// @see \Guzzle\Service\Builder\ServiceBuilder::set()
$builder[$name] = array(
'class' => get_class($client),
'params' => $client->getBuilderParams(),
);
// If the client was previously removed, unset the remove flag.
unset($this->removed[$group][$name]);
return $this;
}
|
@param string $group
@param string $name
@param \Guzzle\Service\Client $client
@return \Acquia\Rest\ServiceManager
|
public function getClient($group, $name)
{
return isset($this[$group][$name]) ? $this[$group][$name] : null;
}
|
@param string $group
@param string $name
@return \Guzzle\Service\Client
|
public function removeClient($group, $name)
{
unset($this[$group][$name]);
$this->removed[$group][$name] = $name;
return $this;
}
|
@param string $group
@param string $name
@return \Acquia\Rest\ServiceManager
|
public function save($overwrite = false)
{
foreach ($this as $group => $builder) {
$this->saveServiceGroup($group, $overwrite);
}
}
|
Writes all service group configurations to the backend.
@param boolean $overwrite
|
public function saveServiceGroup($group, $overwrite = false)
{
$filename = $this->getConfigFilename($group);
$hasConfigFile = $this->hasConfigFile($group);
// This sucks, but it is the only way to get the builder config.
// @todo Create a Guzzle issue to add a getBuilderConfig() method.
$builder = $this[$group];
$builderConfig = Json::decode($builder->serialize());
// @todo Add validation.
if (!$overwrite && $hasConfigFile) {
$groupJson = file_get_contents($filename);
$groupData = Json::decode($groupJson);
$builderConfig = array_merge($groupData['services'], $builderConfig);
}
// Unset the services that are flagged to be removed then clear the
// remove flag since action was taken.
foreach ($this->removed[$group] as $name) {
unset($builderConfig[$name]);
}
$this->removed[$group] = array();
$json = Json::encode(array(
'class' => get_class($builder),
'services' => $builderConfig,
));
$filesystem = $this->getFilesystem();
if (!$hasConfigFile) {
$filesystem->mkdir(dirname($filename), 0755);
}
$filesystem->dumpFile($filename, $json, 0600);
}
|
@param string $group
@param boolean $overwrite
@throws \Symfony\Component\Filesystem\Exception\IOException
@see http://guzzlephp.org/webservice-client/using-the-service-builder.html#sourcing-from-a-json-document
|
public function deleteServiceGroup($group)
{
$filename = $this->getConfigFilename($group);
$this->getFilesystem()->remove($filename);
// Unlike normal arrays, unset() will throw errors here if the key
// doesn't exist.
if (isset($this[$group])) {
unset($this[$group]);
}
unset($this->removed[$group]);
}
|
@param string $group
@throws \Symfony\Component\Filesystem\Exception\IOException
|
public function generate($params = array())
{
if (!is_array($params)) {
throw new \UnexpectedValueException('Expecting data to be an array.');
}
$time = $this->getRequestTime();
$nonce = $this->generateNonce();
$key = $this->getSecretKey();
if (empty($params['rpc_version']) || $params['rpc_version'] < 2) {
$string = $time . ':' . $nonce . ':' . $key . ':' . serialize($params);
return base64_encode(
pack("H*", sha1((str_pad($key, 64, chr(0x00)) ^ (str_repeat(chr(0x5c), 64))) .
pack("H*", sha1((str_pad($key, 64, chr(0x00)) ^ (str_repeat(chr(0x36), 64))) .
$string)))));
} elseif ($params['rpc_version'] == 2) {
$string = $time . ':' . $nonce . ':' . json_encode($params);
return sha1((str_pad($key, 64, chr(0x00)) ^ (str_repeat(chr(0x5c), 64))) . pack("H*", sha1((str_pad($key, 64, chr(0x00)) ^ (str_repeat(chr(0x36), 64))) . $string)));
} else {
$string = $time . ':' . $nonce;
return sha1((str_pad($key, 64, chr(0x00)) ^ (str_repeat(chr(0x5c), 64))) . pack("H*", sha1((str_pad($key, 64, chr(0x00)) ^ (str_repeat(chr(0x36), 64))) . $string)));
}
}
|
{@inheritdoc}
|
public function formatCamoUrl($domain, $digest, $url)
{
return 'https://' . $domain . '/' . $digest . '?url=' . $this->encoder->encode($url);
}
|
@param $domain
@param $digest
@param $url
@return mixed
|
public static function factory($config = null, array $globalParameters = array())
{
if ($config instanceof Subscription) {
$subscription = $config;
if (!isset($subscription['derived_key_salt'])) {
throw new \UnexpectedValueException('Derived key salt not found in subscription');
}
if (!isset($subscription['heartbeat_data']['search_service_colony'])) {
throw new \UnexpectedValueException('Acquia Search hostname not found in subscription');
}
if (!isset($subscription['heartbeat_data']['search_cores'])) {
throw new \UnexpectedValueException('Index data not found in subscription');
}
$derivedKey = new DerivedKey($subscription['derived_key_salt'], $subscription->getKey());
$config = array('services' => array());
foreach ($subscription['heartbeat_data']['search_cores'] as $indexInfo) {
$config['services'][$indexInfo['core_id']] = array(
'class' => 'Acquia\Search\AcquiaSearchClient',
'params' => array(
'base_url' => 'https://' . $indexInfo['balancer'],
'index_id' => $indexInfo['core_id'],
'derived_key' => $derivedKey->generate($indexInfo['core_id']),
),
);
}
}
return parent::factory($config, $globalParameters);
}
|
{@inheritdoc}
@return \Guzzle\Service\Builder\ServiceBuilder
|
public function cancel( $id )
{
$item = $this->manager->getItem( $id );
$item = $item->setDateEnd( $item->getDateNext() )
->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_CANCEL );
return $this->manager->saveItem( $item );
}
|
Cancels an active subscription
@param string $id Unique subscription ID
@return \Aimeos\MShop\Subscription\Item\Iface Canceled subscription item
|
public function get( $id )
{
$context = $this->getContext();
$filter = $this->manager->createSearch( true );
$expr = [
$filter->compare( '==', 'subscription.id', $id ),
$filter->compare( '==', 'order.base.customerid', $context->getUserId() ),
$filter->getConditions(),
];
$filter->setConditions( $filter->combine( '&&', $expr ) );
$items = $this->manager->searchItems( $filter );
if( ( $item = reset( $items ) ) === false )
{
$msg = 'Invalid subscription ID "%1$s" for customer ID "%2$s"';
throw new \Aimeos\Controller\Frontend\Subscription\Exception( sprintf( $msg, $id, $context->getUserId() ) );
}
return $item;
}
|
Returns the subscription item for the given ID
@param string $id Unique subscription ID
@return \Aimeos\MShop\Subscription\Item\Iface Subscription object
|
public function getIntervals()
{
$manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' );
$search = $manager->createSearch( true );
$expr = array(
$search->compare( '==', 'attribute.domain', 'product' ),
$search->compare( '==', 'attribute.type', 'interval' ),
$search->getConditions(),
);
$search->setConditions( $search->combine( '&&', $expr ) );
$search->setSlice( 0, 10000 );
$list = [];
foreach( $manager->searchItems( $search, ['text'] ) as $attrItem ) {
$list[$attrItem->getCode()] = $attrItem;
}
return $list;
}
|
Returns the available interval attribute items
@return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of intervals as keys and interval attribute items as values
|
public function save( \Aimeos\MShop\Subscription\Item\Iface $item )
{
return $this->manager->saveItem( $item );
}
|
Saves the modified subscription item
@param \Aimeos\MShop\Subscription\Item\Iface $item Subscription object
@return \Aimeos\MShop\Subscription\Item\Iface Saved subscription item
|
public function getProvider( $serviceId )
{
$item = $this->manager->getItem( $serviceId, $this->domains, true );
return $this->manager->getProvider( $item, $item->getType() );
}
|
Returns the service item for the given ID
@param string $serviceId Unique service ID
@return \Aimeos\MShop\Service\Provider\Iface Service provider object
|
public function getProviders()
{
$list = [];
$this->filter->setConditions( $this->filter->combine( '&&', $this->conditions ) );
foreach( $this->manager->searchItems( $this->filter, $this->domains ) as $id => $item ) {
$list[$id] = $this->manager->getProvider( $item, $item->getType() );
}
return $list;
}
|
Returns the service providers of the given type
@return \Aimeos\MShop\Service\Provider\Iface[] List of service IDs as keys and service provider objects as values
|
public function process( \Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params )
{
$item = $this->manager->getItem( $serviceId, [], true );
$provider = $this->manager->getProvider( $item, $item->getType() );
$provider->injectGlobalConfigBE( $urls );
return $provider->process( $orderItem, $params );
}
|
Processes the service for the given order, e.g. payment and delivery services
@param \Aimeos\MShop\Order\Item\Iface $orderItem Order which should be processed
@param string $serviceId Unique service item ID
@param array $urls Associative list of keys and the corresponding URLs
(keys are <type>.url-self, <type>.url-success, <type>.url-update where type can be "delivery" or "payment")
@param array $params Request parameters and order service attributes
@return \Aimeos\MShop\Common\Helper\Form\Iface|null Form object with URL, parameters, etc.
or null if no form data is required
|
public function type( $code )
{
if( $code ) {
$this->conditions[] = $this->filter->compare( '==', 'service.type', $code );
}
return $this;
}
|
Adds attribute types for filtering
@param array|string $code Service type or list of types
@return \Aimeos\Controller\Frontend\Service\Iface Service controller for fluent interface
@since 2019.04
|
public function updatePush( ServerRequestInterface $request, ResponseInterface $response, $code )
{
$item = $this->manager->findItem( $code );
$provider = $this->manager->getProvider( $item, $item->getType() );
return $provider->updatePush( $request, $response );
}
|
Updates the order status sent by payment gateway notifications
@param ServerRequestInterface $request Request object
@param ResponseInterface $response Response object that will contain HTTP status and response body
@param string $code Unique code of the service used for the current order
@return \Psr\Http\Message\ResponseInterface Response object
|
public function updateSync( ServerRequestInterface $request, $code, $orderid )
{
$orderItem = \Aimeos\MShop::create( $this->getContext(), 'order' )->getItem( $orderid );
$serviceItem = $this->manager->findItem( $code );
$provider = $this->manager->getProvider( $serviceItem, $serviceItem->getType() );
if( ( $orderItem = $provider->updateSync( $request, $orderItem ) ) !== null )
{
if( $orderItem->getPaymentStatus() === \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED
&& $provider->isImplemented( \Aimeos\MShop\Service\Provider\Payment\Base::FEAT_QUERY )
) {
$provider->query( $orderItem );
}
}
return $orderItem;
}
|
Updates the payment or delivery status for the given request
@param ServerRequestInterface $request Request object with parameters and request body
@param string $code Unique code of the service used for the current order
@param string $orderid ID of the order whose payment status should be updated
@return \Aimeos\MShop\Order\Item\Iface $orderItem Order item that has been updated
|
public static function factory($config = array())
{
// We just use this for validation. The configs are set in the parent's
// factory methid.
Collection::fromConfig($config, array(), array('index_id', 'derived_key'));
$solr = parent::factory($config);
// Get the configs relevant to Acquia Search.
$indexId = $solr->getConfig('index_id');
$derivedKey = $solr->getConfig('derived_key');
// Set the base bath to point to the configured index.
$solr->getConfig()->set('base_path', '/solr/' . $indexId);
// Attach the Acquia Search HMAC Authentication plugin to the client.
$signature = new Signature($derivedKey);
$plugin = new AcquiaSearchAuthPlugin($indexId, $signature);
$solr->addSubscriber($plugin);
return $solr;
}
|
{@inheritdoc}
Sets the HMAC authentication plugin, sets the base_path to point to the
correct index.
|
protected function read()
{
$contents = $this->filesystem()->get($this->path);
$data = json_decode($contents, true);
if (is_null($data)) {
throw new RuntimeException("Invalid JSON file in [{$this->path}]");
}
return (array) $data;
}
|
Read the data from the store.
@return array
|
protected function write(array $data)
{
$contents = $data ? json_encode($data) : '{}';
$this->filesystem()->put($this->path, $contents);
}
|
Write the data into the store.
@param array $data
|
public function save( \Aimeos\MShop\Order\Item\Iface $orderItem )
{
return $this->controller->save( $orderItem );
}
|
Updates the given order item in the storage
@param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object
@return \Aimeos\MShop\Order\Item\Iface $orderItem Saved order item object
@since 2019.04
|
public static function create( \Aimeos\MShop\Context\Item\Iface $context, $path )
{
if( empty( $path ) ) {
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Controller path is empty' ) );
}
if( self::$cache === false || !isset( self::$objects[$path] ) )
{
if( ctype_alnum( $path ) === false ) {
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in controller name "%1$s"', $path ) );
}
$factory = '\\Aimeos\\Controller\\Frontend\\' . ucfirst( $path ) . '\\Factory';
if( class_exists( $factory ) === false ) {
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $factory ) );
}
if( ( $controller = call_user_func_array( [$factory, 'create'], [$context] ) ) === false ) {
throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) );
}
self::$objects[$path] = $controller;
}
return clone self::$objects[$path];
}
|
Creates the required controller specified by the given path of controller names
Controllers are created by providing only the domain name, e.g.
"basket" for the \Aimeos\Controller\Frontend\Basket\Standard or a path of names to
retrieve a specific sub-controller if available.
Please note, that only the default controllers can be created. If you need
a specific implementation, you need to use the factory class of the
controller to hand over specifc implementation names.
@param \Aimeos\MShop\Context\Item\Iface $context Context object required by managers
@param string $path Name of the domain (and sub-managers) separated by slashes, e.g "basket"
@return \Aimeos\Controller\Frontend\Iface New frontend controller
@throws \Aimeos\Controller\Frontend\Exception If the given path is invalid or the manager wasn't found
|
public static function inject( $path, \Aimeos\Controller\Frontend\Iface $object = null )
{
self::$objects[$path] = $object;
}
|
Injects a manager object for the given path of manager names
This method is for testing only and you must call \Aimeos\MShop::cache( false )
afterwards!
@param string $path Name of the domain (and sub-controllers) separated by slashes, e.g "product"
@param \Aimeos\Controller\Frontend\Iface|null $object Frontend controller object for the given name or null to clear
|
public function generate($indexId)
{
$string = $indexId . 'solr' . $this->salt;
return hash_hmac('sha1', str_pad($string, 80, $string), $this->networkKey);
}
|
@param string $indexId
The unique identifier of the index, e.g. ABCD-12345.
@return string
|
public function render(ItemInterface $item, array $options = []): string
{
return $this->engine->render($options['template'], ['menu' => $item, 'options' => $options]);
}
|
Render Menu.
@return string
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.