@@ -10,42 +10,42 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $enc = $this->encoder(); |
| 12 | 12 | |
| 13 | -$target = $this->config( 'client/jsonapi/url/target' ); |
|
| 14 | -$cntl = $this->config( 'client/jsonapi/url/controller', 'jsonapi' ); |
|
| 15 | -$action = $this->config( 'client/jsonapi/url/action', 'get' ); |
|
| 16 | -$config = $this->config( 'client/jsonapi/url/config', [] ); |
|
| 13 | +$target = $this->config('client/jsonapi/url/target'); |
|
| 14 | +$cntl = $this->config('client/jsonapi/url/controller', 'jsonapi'); |
|
| 15 | +$action = $this->config('client/jsonapi/url/action', 'get'); |
|
| 16 | +$config = $this->config('client/jsonapi/url/config', []); |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | -$total = $this->get( 'total', 0 ); |
|
| 20 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
| 21 | -$limit = max( $this->param( 'page/limit', 100 ), 1 ); |
|
| 19 | +$total = $this->get('total', 0); |
|
| 20 | +$offset = max($this->param('page/offset', 0), 0); |
|
| 21 | +$limit = max($this->param('page/limit', 100), 1); |
|
| 22 | 22 | |
| 23 | -$first = ( $offset > 0 ? 0 : null ); |
|
| 24 | -$prev = ( $offset - $limit >= 0 ? $offset - $limit : null ); |
|
| 25 | -$next = ( $offset + $limit < $total ? $offset + $limit : null ); |
|
| 26 | -$last = ( ( (int) ( $total / $limit ) ) * $limit > $offset ? ( (int) ( $total / $limit ) ) * $limit : null ); |
|
| 23 | +$first = ($offset > 0 ? 0 : null); |
|
| 24 | +$prev = ($offset - $limit >= 0 ? $offset - $limit : null); |
|
| 25 | +$next = ($offset + $limit < $total ? $offset + $limit : null); |
|
| 26 | +$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null); |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | -$ref = array( 'resource', 'id', 'related', 'relatedid', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
| 30 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ); |
|
| 29 | +$ref = array('resource', 'id', 'related', 'relatedid', 'filter', 'page', 'sort', 'include', 'fields'); |
|
| 30 | +$params = array_intersect_key($this->param(), array_flip($ref)); |
|
| 31 | 31 | |
| 32 | -$pretty = $this->param( 'pretty' ) ? JSON_PRETTY_PRINT : 0; |
|
| 33 | -$fields = $this->param( 'fields', [] ); |
|
| 32 | +$pretty = $this->param('pretty') ? JSON_PRETTY_PRINT : 0; |
|
| 33 | +$fields = $this->param('fields', []); |
|
| 34 | 34 | |
| 35 | -foreach( (array) $fields as $resource => $list ) { |
|
| 36 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
| 35 | +foreach ((array) $fields as $resource => $list) { |
|
| 36 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | -$entryFcn = function( \Aimeos\MShop\Cms\Item\Iface $item ) use ( $fields, $target, $cntl, $action, $config ) |
|
| 40 | +$entryFcn = function(\Aimeos\MShop\Cms\Item\Iface $item) use ($fields, $target, $cntl, $action, $config) |
|
| 41 | 41 | { |
| 42 | 42 | $id = $item->getId(); |
| 43 | 43 | $type = $item->getResourceType(); |
| 44 | - $params = array( 'resource' => $type, 'id' => $id ); |
|
| 44 | + $params = array('resource' => $type, 'id' => $id); |
|
| 45 | 45 | $attributes = $item->toArray(); |
| 46 | 46 | |
| 47 | - if( isset( $fields[$type] ) ) { |
|
| 48 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
| 47 | + if (isset($fields[$type])) { |
|
| 48 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $entry = array( |
@@ -53,26 +53,26 @@ discard block |
||
| 53 | 53 | 'type' => $type, |
| 54 | 54 | 'links' => array( |
| 55 | 55 | 'self' => array( |
| 56 | - 'href' => $this->url( $target, $cntl, $action, $params, [], $config ), |
|
| 57 | - 'allow' => array( 'GET' ), |
|
| 56 | + 'href' => $this->url($target, $cntl, $action, $params, [], $config), |
|
| 57 | + 'allow' => array('GET'), |
|
| 58 | 58 | ), |
| 59 | 59 | ), |
| 60 | 60 | 'attributes' => $attributes, |
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | - foreach( $item->getListItems() as $listItem ) |
|
| 63 | + foreach ($item->getListItems() as $listItem) |
|
| 64 | 64 | { |
| 65 | - if( ( $refItem = $listItem->getRefItem() ) !== null && $refItem->isAvailable() ) |
|
| 65 | + if (($refItem = $listItem->getRefItem()) !== null && $refItem->isAvailable()) |
|
| 66 | 66 | { |
| 67 | 67 | $ltype = $listItem->getResourceType(); |
| 68 | 68 | $type = $refItem->getResourceType(); |
| 69 | 69 | $attributes = $listItem->toArray(); |
| 70 | 70 | |
| 71 | - if( isset( $fields[$ltype] ) ) { |
|
| 72 | - $attributes = array_intersect_key( $attributes, $fields[$ltype] ); |
|
| 71 | + if (isset($fields[$ltype])) { |
|
| 72 | + $attributes = array_intersect_key($attributes, $fields[$ltype]); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $data = array( 'id' => $refItem->getId(), 'type' => $type, 'attributes' => $attributes ); |
|
| 75 | + $data = array('id' => $refItem->getId(), 'type' => $type, 'attributes' => $attributes); |
|
| 76 | 76 | $entry['relationships'][$type]['data'][] = $data; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | "meta": { |
| 87 | 87 | "total": <?= $total; ?>, |
| 88 | - "prefix": <?= json_encode( $this->get( 'prefix' ) ); ?>, |
|
| 89 | - "content-baseurl": "<?= $this->config( 'resource/fs/baseurl' ); ?>" |
|
| 90 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
| 88 | + "prefix": <?= json_encode($this->get('prefix')); ?>, |
|
| 89 | + "content-baseurl": "<?= $this->config('resource/fs/baseurl'); ?>" |
|
| 90 | + <?php if ($this->csrf()->name() != '') : ?> |
|
| 91 | 91 | , "csrf": { |
| 92 | 92 | "name": "<?= $this->csrf()->name(); ?>", |
| 93 | 93 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -96,46 +96,46 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | }, |
| 98 | 98 | "links": { |
| 99 | - <?php if( is_map( $this->get( 'items' ) ) ) : ?> |
|
| 100 | - <?php if( $first !== null ) : ?> |
|
| 101 | - "first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
| 99 | + <?php if (is_map($this->get('items'))) : ?> |
|
| 100 | + <?php if ($first !== null) : ?> |
|
| 101 | + "first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
| 102 | 102 | <?php endif; ?> |
| 103 | - <?php if( $prev !== null ) : ?> |
|
| 104 | - "prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
| 103 | + <?php if ($prev !== null) : ?> |
|
| 104 | + "prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
| 105 | 105 | <?php endif; ?> |
| 106 | - <?php if( $next !== null ) : ?> |
|
| 107 | - "next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
| 106 | + <?php if ($next !== null) : ?> |
|
| 107 | + "next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
| 108 | 108 | <?php endif; ?> |
| 109 | - <?php if( $last !== null ) : ?> |
|
| 110 | - "last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
| 109 | + <?php if ($last !== null) : ?> |
|
| 110 | + "last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
| 111 | 111 | <?php endif; ?> |
| 112 | 112 | <?php endif; ?> |
| 113 | - "self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>" |
|
| 113 | + "self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, [], $config); ?>" |
|
| 114 | 114 | } |
| 115 | - <?php if( isset( $this->errors ) ) : ?> |
|
| 116 | - ,"errors": <?= json_encode( $this->errors, $pretty ); ?> |
|
| 115 | + <?php if (isset($this->errors)) : ?> |
|
| 116 | + ,"errors": <?= json_encode($this->errors, $pretty); ?> |
|
| 117 | 117 | |
| 118 | - <?php elseif( isset( $this->items ) ) : ?> |
|
| 118 | + <?php elseif (isset($this->items)) : ?> |
|
| 119 | 119 | <?php |
| 120 | 120 | $data = []; |
| 121 | - $items = $this->get( 'items', map() ); |
|
| 122 | - $included = $this->jincluded( $items, $fields ); |
|
| 121 | + $items = $this->get('items', map()); |
|
| 122 | + $included = $this->jincluded($items, $fields); |
|
| 123 | 123 | |
| 124 | - if( is_map( $items ) ) |
|
| 124 | + if (is_map($items)) |
|
| 125 | 125 | { |
| 126 | - foreach( $items as $item ) { |
|
| 127 | - $data[] = $entryFcn( $item ); |
|
| 126 | + foreach ($items as $item) { |
|
| 127 | + $data[] = $entryFcn($item); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | else |
| 131 | 131 | { |
| 132 | - $data = $entryFcn( $items ); |
|
| 132 | + $data = $entryFcn($items); |
|
| 133 | 133 | } |
| 134 | 134 | ?> |
| 135 | 135 | |
| 136 | - ,"data": <?= json_encode( $data, $pretty ); ?> |
|
| 136 | + ,"data": <?= json_encode($data, $pretty); ?> |
|
| 137 | 137 | |
| 138 | - ,"included": <?= map( $included )->flat( 1 )->toJson( $pretty ) ?> |
|
| 138 | + ,"included": <?= map($included)->flat(1)->toJson($pretty) ?> |
|
| 139 | 139 | |
| 140 | 140 | <?php endif; ?> |
| 141 | 141 | |
@@ -126,8 +126,7 @@ |
||
| 126 | 126 | foreach( $items as $item ) { |
| 127 | 127 | $data[] = $entryFcn( $item ); |
| 128 | 128 | } |
| 129 | - } |
|
| 130 | - else |
|
| 129 | + } else |
|
| 131 | 130 | { |
| 132 | 131 | $data = $entryFcn( $items ); |
| 133 | 132 | } |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | $context = \TestHelperJapi::getContext(); |
| 17 | 17 | |
| 18 | - $client = \Aimeos\Client\JsonApi\Cms\Factory::create( $context, 'cms' ); |
|
| 19 | - $this->assertInstanceOf( \Aimeos\Client\JsonApi\Iface::class, $client ); |
|
| 18 | + $client = \Aimeos\Client\JsonApi\Cms\Factory::create($context, 'cms'); |
|
| 19 | + $this->assertInstanceOf(\Aimeos\Client\JsonApi\Iface::class, $client); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $context = \TestHelperJapi::getContext(); |
| 26 | 26 | |
| 27 | - $this->expectException( \Aimeos\Client\JsonApi\Exception::class ); |
|
| 28 | - \Aimeos\Client\JsonApi\Cms\Factory::create( $context, '' ); |
|
| 27 | + $this->expectException(\Aimeos\Client\JsonApi\Exception::class); |
|
| 28 | + \Aimeos\Client\JsonApi\Cms\Factory::create($context, ''); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $context = \TestHelperJapi::getContext(); |
| 35 | 35 | |
| 36 | - $this->expectException( \Aimeos\Client\JsonApi\Exception::class ); |
|
| 37 | - \Aimeos\Client\JsonApi\Cms\Factory::create( $context, '%^' ); |
|
| 36 | + $this->expectException(\Aimeos\Client\JsonApi\Exception::class); |
|
| 37 | + \Aimeos\Client\JsonApi\Cms\Factory::create($context, '%^'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $context = \TestHelperJapi::getContext(); |
| 44 | 44 | |
| 45 | - $this->expectException( \Aimeos\Client\JsonApi\Exception::class ); |
|
| 46 | - \Aimeos\Client\JsonApi\Cms\Factory::create( $context, 'cms', '%^' ); |
|
| 45 | + $this->expectException(\Aimeos\Client\JsonApi\Exception::class); |
|
| 46 | + \Aimeos\Client\JsonApi\Cms\Factory::create($context, 'cms', '%^'); |
|
| 47 | 47 | } |
| 48 | 48 | } |
@@ -19,18 +19,18 @@ discard block |
||
| 19 | 19 | protected function setUp() : void |
| 20 | 20 | { |
| 21 | 21 | $this->context = \TestHelperJapi::getContext(); |
| 22 | - $this->context->getLocale()->setLanguageId( 'en' ); |
|
| 22 | + $this->context->getLocale()->setLanguageId('en'); |
|
| 23 | 23 | $this->view = $this->context->getView(); |
| 24 | 24 | |
| 25 | - $this->object = new \Aimeos\Client\JsonApi\Cms\Standard( $this->context, 'cms' ); |
|
| 26 | - $this->object->setView( $this->view ); |
|
| 25 | + $this->object = new \Aimeos\Client\JsonApi\Cms\Standard($this->context, 'cms'); |
|
| 26 | + $this->object->setView($this->view); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | public function testGetItem() |
| 31 | 31 | { |
| 32 | - $manager = \Aimeos\MShop::create( $this->context, 'cms' ); |
|
| 33 | - $pageId = $manager->find( '/contact' )->getId(); |
|
| 32 | + $manager = \Aimeos\MShop::create($this->context, 'cms'); |
|
| 33 | + $pageId = $manager->find('/contact')->getId(); |
|
| 34 | 34 | |
| 35 | 35 | $params = array( |
| 36 | 36 | 'id' => $pageId, |
@@ -41,22 +41,22 @@ discard block |
||
| 41 | 41 | 'include' => 'text' |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 45 | - $this->view->addHelper( 'param', $helper ); |
|
| 44 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 45 | + $this->view->addHelper('param', $helper); |
|
| 46 | 46 | |
| 47 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 48 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 47 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 48 | + $result = json_decode((string) $response->getBody(), true); |
|
| 49 | 49 | |
| 50 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 51 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
| 52 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 50 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 51 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
| 52 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 53 | 53 | |
| 54 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 55 | - $this->assertEquals( 'cms', $result['data']['type'] ); |
|
| 56 | - $this->assertEquals( 3, count( $result['data']['relationships']['text']['data'] ) ); |
|
| 57 | - $this->assertEquals( 3, count( $result['included'] ) ); |
|
| 54 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 55 | + $this->assertEquals('cms', $result['data']['type']); |
|
| 56 | + $this->assertEquals(3, count($result['data']['relationships']['text']['data'])); |
|
| 57 | + $this->assertEquals(3, count($result['included'])); |
|
| 58 | 58 | |
| 59 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 59 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $params = array( |
| 66 | 66 | 'filter' => array( |
| 67 | - '=~' => array( 'cms.url' => '/cont' ), |
|
| 67 | + '=~' => array('cms.url' => '/cont'), |
|
| 68 | 68 | ), |
| 69 | 69 | 'fields' => array( |
| 70 | 70 | 'cms' => 'cms.id,cms.label,cms.url' |
@@ -72,23 +72,23 @@ discard block |
||
| 72 | 72 | 'include' => 'text', |
| 73 | 73 | 'sort' => 'cms.label,-cms.id', |
| 74 | 74 | ); |
| 75 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 76 | - $this->view->addHelper( 'param', $helper ); |
|
| 75 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 76 | + $this->view->addHelper('param', $helper); |
|
| 77 | 77 | |
| 78 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 79 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 78 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 79 | + $result = json_decode((string) $response->getBody(), true); |
|
| 80 | 80 | |
| 81 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 82 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
| 83 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 81 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 82 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
| 83 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 84 | 84 | |
| 85 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 86 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 87 | - $this->assertEquals( 'cms', $result['data'][0]['type'] ); |
|
| 88 | - $this->assertEquals( 3, count( $result['data'][0]['attributes'] ) ); |
|
| 89 | - $this->assertEquals( 3, count( $result['included'] ) ); |
|
| 85 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 86 | + $this->assertEquals(1, count($result['data'])); |
|
| 87 | + $this->assertEquals('cms', $result['data'][0]['type']); |
|
| 88 | + $this->assertEquals(3, count($result['data'][0]['attributes'])); |
|
| 89 | + $this->assertEquals(3, count($result['included'])); |
|
| 90 | 90 | |
| 91 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 91 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -96,78 +96,78 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $params = array( |
| 98 | 98 | 'filter' => array( |
| 99 | - '=~' => array( 'cms.url' => '/contact' ), |
|
| 99 | + '=~' => array('cms.url' => '/contact'), |
|
| 100 | 100 | ), |
| 101 | 101 | 'sort' => 'cms.label', |
| 102 | 102 | ); |
| 103 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 104 | - $this->view->addHelper( 'param', $helper ); |
|
| 103 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 104 | + $this->view->addHelper('param', $helper); |
|
| 105 | 105 | |
| 106 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 107 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 106 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 107 | + $result = json_decode((string) $response->getBody(), true); |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 111 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 112 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 110 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 111 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 112 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | |
| 116 | 116 | public function testGetMShopException() |
| 117 | 117 | { |
| 118 | - $object = $this->getMockBuilder( \Aimeos\Client\JsonApi\Cms\Standard::class ) |
|
| 119 | - ->setConstructorArgs( [$this->context, 'cms'] ) |
|
| 120 | - ->setMethods( ['getItems'] ) |
|
| 118 | + $object = $this->getMockBuilder(\Aimeos\Client\JsonApi\Cms\Standard::class) |
|
| 119 | + ->setConstructorArgs([$this->context, 'cms']) |
|
| 120 | + ->setMethods(['getItems']) |
|
| 121 | 121 | ->getMock(); |
| 122 | 122 | |
| 123 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
| 124 | - ->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
|
| 123 | + $object->expects($this->once())->method('getItems') |
|
| 124 | + ->will($this->throwException(new \Aimeos\MShop\Exception())); |
|
| 125 | 125 | |
| 126 | - $object->setView( $this->view ); |
|
| 126 | + $object->setView($this->view); |
|
| 127 | 127 | |
| 128 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
| 129 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 128 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
| 129 | + $result = json_decode((string) $response->getBody(), true); |
|
| 130 | 130 | |
| 131 | 131 | |
| 132 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
| 133 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 132 | + $this->assertEquals(404, $response->getStatusCode()); |
|
| 133 | + $this->assertArrayHasKey('errors', $result); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | public function testGetException() |
| 138 | 138 | { |
| 139 | - $object = $this->getMockBuilder( \Aimeos\Client\JsonApi\Cms\Standard::class ) |
|
| 140 | - ->setConstructorArgs( [$this->context, 'cms'] ) |
|
| 141 | - ->setMethods( ['getItems'] ) |
|
| 139 | + $object = $this->getMockBuilder(\Aimeos\Client\JsonApi\Cms\Standard::class) |
|
| 140 | + ->setConstructorArgs([$this->context, 'cms']) |
|
| 141 | + ->setMethods(['getItems']) |
|
| 142 | 142 | ->getMock(); |
| 143 | 143 | |
| 144 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
| 145 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 144 | + $object->expects($this->once())->method('getItems') |
|
| 145 | + ->will($this->throwException(new \Exception())); |
|
| 146 | 146 | |
| 147 | - $object->setView( $this->view ); |
|
| 147 | + $object->setView($this->view); |
|
| 148 | 148 | |
| 149 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
| 150 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 149 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
| 150 | + $result = json_decode((string) $response->getBody(), true); |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
| 154 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 153 | + $this->assertEquals(500, $response->getStatusCode()); |
|
| 154 | + $this->assertArrayHasKey('errors', $result); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | public function testOptions() |
| 159 | 159 | { |
| 160 | - $response = $this->object->options( $this->view->request(), $this->view->response() ); |
|
| 161 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 162 | - |
|
| 163 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 164 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
| 165 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 166 | - |
|
| 167 | - $this->assertEquals( null, $result['meta']['prefix'] ); |
|
| 168 | - $this->assertArrayNotHasKey( 'attributes', $result['meta'] ); |
|
| 169 | - $this->assertArrayNotHasKey( 'filter', $result['meta'] ); |
|
| 170 | - $this->assertArrayNotHasKey( 'sort', $result['meta'] ); |
|
| 171 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 160 | + $response = $this->object->options($this->view->request(), $this->view->response()); |
|
| 161 | + $result = json_decode((string) $response->getBody(), true); |
|
| 162 | + |
|
| 163 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 164 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
| 165 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 166 | + |
|
| 167 | + $this->assertEquals(null, $result['meta']['prefix']); |
|
| 168 | + $this->assertArrayNotHasKey('attributes', $result['meta']); |
|
| 169 | + $this->assertArrayNotHasKey('filter', $result['meta']); |
|
| 170 | + $this->assertArrayNotHasKey('sort', $result['meta']); |
|
| 171 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 172 | 172 | } |
| 173 | 173 | } |
@@ -13,16 +13,16 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | $includepaths = $aimeos->getIncludePaths(); |
| 15 | 15 | $includepaths[] = get_include_path(); |
| 16 | - set_include_path( implode( PATH_SEPARATOR, $includepaths ) ); |
|
| 16 | + set_include_path(implode(PATH_SEPARATOR, $includepaths)); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | private static function getAimeos() |
| 21 | 21 | { |
| 22 | - if( !isset( self::$aimeos ) ) |
|
| 22 | + if (!isset(self::$aimeos)) |
|
| 23 | 23 | { |
| 24 | 24 | require_once 'Bootstrap.php'; |
| 25 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
| 25 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
| 26 | 26 | |
| 27 | 27 | self::$aimeos = new \Aimeos\Bootstrap(); |
| 28 | 28 | } |
@@ -31,43 +31,43 @@ discard block |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - public static function getContext( $site = 'unittest' ) |
|
| 34 | + public static function getContext($site = 'unittest') |
|
| 35 | 35 | { |
| 36 | - if( !isset( self::$context[$site] ) ) { |
|
| 37 | - self::$context[$site] = self::createContext( $site ); |
|
| 38 | - self::$context[$site]->setView( self::getView( self::$context[$site]->getConfig() ) ); |
|
| 36 | + if (!isset(self::$context[$site])) { |
|
| 37 | + self::$context[$site] = self::createContext($site); |
|
| 38 | + self::$context[$site]->setView(self::getView(self::$context[$site]->getConfig())); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return clone self::$context[$site]; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - public static function getView( \Aimeos\MW\Config\Iface $config ) |
|
| 45 | + public static function getView(\Aimeos\MW\Config\Iface $config) |
|
| 46 | 46 | { |
| 47 | - $view = new \Aimeos\MW\View\Standard( self::getTemplatePaths() ); |
|
| 47 | + $view = new \Aimeos\MW\View\Standard(self::getTemplatePaths()); |
|
| 48 | 48 | |
| 49 | - $trans = new \Aimeos\MW\Translation\None( 'en' ); |
|
| 50 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans ); |
|
| 51 | - $view->addHelper( 'translate', $helper ); |
|
| 49 | + $trans = new \Aimeos\MW\Translation\None('en'); |
|
| 50 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans); |
|
| 51 | + $view->addHelper('translate', $helper); |
|
| 52 | 52 | |
| 53 | - $helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'baseurl' ); |
|
| 54 | - $view->addHelper( 'url', $helper ); |
|
| 53 | + $helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'baseurl'); |
|
| 54 | + $view->addHelper('url', $helper); |
|
| 55 | 55 | |
| 56 | - $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' ); |
|
| 57 | - $view->addHelper( 'number', $helper ); |
|
| 56 | + $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', ''); |
|
| 57 | + $view->addHelper('number', $helper); |
|
| 58 | 58 | |
| 59 | - $helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
|
| 60 | - $view->addHelper( 'date', $helper ); |
|
| 59 | + $helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d'); |
|
| 60 | + $view->addHelper('date', $helper); |
|
| 61 | 61 | |
| 62 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
| 63 | - $view->addHelper( 'config', $helper ); |
|
| 62 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
| 63 | + $view->addHelper('config', $helper); |
|
| 64 | 64 | |
| 65 | 65 | $psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory(); |
| 66 | - $helper = new \Aimeos\MW\View\Helper\Request\Standard( $view, $psr17Factory->createServerRequest( 'GET', 'https://aimeos.org' ) ); |
|
| 67 | - $view->addHelper( 'request', $helper ); |
|
| 66 | + $helper = new \Aimeos\MW\View\Helper\Request\Standard($view, $psr17Factory->createServerRequest('GET', 'https://aimeos.org')); |
|
| 67 | + $view->addHelper('request', $helper); |
|
| 68 | 68 | |
| 69 | - $helper = new \Aimeos\MW\View\Helper\Response\Standard( $view, $psr17Factory->createResponse() ); |
|
| 70 | - $view->addHelper( 'response', $helper ); |
|
| 69 | + $helper = new \Aimeos\MW\View\Helper\Response\Standard($view, $psr17Factory->createResponse()); |
|
| 70 | + $view->addHelper('response', $helper); |
|
| 71 | 71 | |
| 72 | 72 | return $view; |
| 73 | 73 | } |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public static function getTemplatePaths() |
| 77 | 77 | { |
| 78 | - return self::getAimeos()->getCustomPaths( 'client/jsonapi/templates' ); |
|
| 78 | + return self::getAimeos()->getCustomPaths('client/jsonapi/templates'); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - private static function createContext( $site ) |
|
| 82 | + private static function createContext($site) |
|
| 83 | 83 | { |
| 84 | 84 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
| 85 | 85 | $aimeos = self::getAimeos(); |
@@ -88,36 +88,36 @@ discard block |
||
| 88 | 88 | $paths = $aimeos->getConfigPaths(); |
| 89 | 89 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
| 90 | 90 | |
| 91 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), $paths ); |
|
| 92 | - $ctx->setConfig( $conf ); |
|
| 91 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); |
|
| 92 | + $ctx->setConfig($conf); |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | - $dbm = new \Aimeos\MW\DB\Manager\DBAL( $conf ); |
|
| 96 | - $ctx->setDatabaseManager( $dbm ); |
|
| 95 | + $dbm = new \Aimeos\MW\DB\Manager\DBAL($conf); |
|
| 96 | + $ctx->setDatabaseManager($dbm); |
|
| 97 | 97 | |
| 98 | 98 | |
| 99 | - $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
| 100 | - $ctx->setLogger( $logger ); |
|
| 99 | + $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
| 100 | + $ctx->setLogger($logger); |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | $cache = new \Aimeos\MW\Cache\None(); |
| 104 | - $ctx->setCache( $cache ); |
|
| 104 | + $ctx->setCache($cache); |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | - $i18n = new \Aimeos\MW\Translation\None( 'en' ); |
|
| 108 | - $ctx->setI18n( array( 'en' => $i18n ) ); |
|
| 107 | + $i18n = new \Aimeos\MW\Translation\None('en'); |
|
| 108 | + $ctx->setI18n(array('en' => $i18n)); |
|
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | $session = new \Aimeos\MW\Session\None(); |
| 112 | - $ctx->setSession( $session ); |
|
| 112 | + $ctx->setSession($session); |
|
| 113 | 113 | |
| 114 | 114 | |
| 115 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
|
| 116 | - $locale = $localeManager->bootstrap( $site, '', '', false ); |
|
| 117 | - $ctx->setLocale( $locale ); |
|
| 115 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create($ctx); |
|
| 116 | + $locale = $localeManager->bootstrap($site, '', '', false); |
|
| 117 | + $ctx->setLocale($locale); |
|
| 118 | 118 | |
| 119 | 119 | |
| 120 | - $ctx->setEditor( 'ai-cms-grapesjs:client/jsonapi' ); |
|
| 120 | + $ctx->setEditor('ai-cms-grapesjs:client/jsonapi'); |
|
| 121 | 121 | |
| 122 | 122 | return $ctx; |
| 123 | 123 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @return \Aimeos\Client\Html\Iface Page part implementing \Aimeos\Client\Html\Iface |
| 30 | 30 | * @throws \Aimeos\Client\Html\Exception If requested client implementation couldn't be found or initialisation fails |
| 31 | 31 | */ |
| 32 | - public static function create( \Aimeos\MShop\Context\Item\Iface $context, string $name = null ) : \Aimeos\Client\Html\Iface |
|
| 32 | + public static function create(\Aimeos\MShop\Context\Item\Iface $context, string $name = null) : \Aimeos\Client\Html\Iface |
|
| 33 | 33 | { |
| 34 | 34 | /** client/html/cms/page/name |
| 35 | 35 | * Class name of the used cms page client implementation |
@@ -64,20 +64,20 @@ discard block |
||
| 64 | 64 | * @since 2021.04 |
| 65 | 65 | * @category Developer |
| 66 | 66 | */ |
| 67 | - if( $name === null ) { |
|
| 68 | - $name = $context->getConfig()->get( 'client/html/cms/page/name', 'Standard' ); |
|
| 67 | + if ($name === null) { |
|
| 68 | + $name = $context->getConfig()->get('client/html/cms/page/name', 'Standard'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $iface = '\\Aimeos\\Client\\Html\\Iface'; |
| 72 | 72 | $classname = '\\Aimeos\\Client\\Html\\Cms\\Page\\' . $name; |
| 73 | 73 | |
| 74 | - if( ctype_alnum( $name ) === false ) { |
|
| 75 | - throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
| 74 | + if (ctype_alnum($name) === false) { |
|
| 75 | + throw new \Aimeos\Client\Html\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $client = self::createClient( $context, $classname, $iface ); |
|
| 79 | - $client = self::addClientDecorators( $context, $client, 'cms/page' ); |
|
| 78 | + $client = self::createClient($context, $classname, $iface); |
|
| 79 | + $client = self::addClientDecorators($context, $client, 'cms/page'); |
|
| 80 | 80 | |
| 81 | - return $client->setObject( $client ); |
|
| 81 | + return $client->setObject($client); |
|
| 82 | 82 | } |
| 83 | 83 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
| 69 | 69 | * @return string HTML code |
| 70 | 70 | */ |
| 71 | - public function getBody( string $uid = '' ) : string |
|
| 71 | + public function getBody(string $uid = '') : string |
|
| 72 | 72 | { |
| 73 | 73 | $prefixes = ['path']; |
| 74 | 74 | $context = $this->getContext(); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | $confkey = 'client/html/cms/page'; |
| 102 | 102 | |
| 103 | - if( ( $html = $this->getCached( 'body', $uid, $prefixes, $confkey ) ) === null ) |
|
| 103 | + if (($html = $this->getCached('body', $uid, $prefixes, $confkey)) === null) |
|
| 104 | 104 | { |
| 105 | 105 | $view = $this->getView(); |
| 106 | 106 | |
@@ -131,47 +131,47 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | $html = ''; |
| 133 | 133 | |
| 134 | - if( !isset( $this->view ) ) { |
|
| 135 | - $view = $this->view = $this->getObject()->addData( $view, $this->tags, $this->expire ); |
|
| 134 | + if (!isset($this->view)) { |
|
| 135 | + $view = $this->view = $this->getObject()->addData($view, $this->tags, $this->expire); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 139 | - $html .= $subclient->setView( $view )->getBody( $uid ); |
|
| 138 | + foreach ($this->getSubClients() as $subclient) { |
|
| 139 | + $html .= $subclient->setView($view)->getBody($uid); |
|
| 140 | 140 | } |
| 141 | 141 | $view->pageBody = $html; |
| 142 | 142 | |
| 143 | - $html = $view->render( $view->config( $tplconf, $default ) ); |
|
| 144 | - $this->setCached( 'body', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire ); |
|
| 143 | + $html = $view->render($view->config($tplconf, $default)); |
|
| 144 | + $this->setCached('body', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire); |
|
| 145 | 145 | |
| 146 | 146 | return $html; |
| 147 | 147 | } |
| 148 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 148 | + catch (\Aimeos\Client\Html\Exception $e) |
|
| 149 | 149 | { |
| 150 | - $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 151 | - $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
|
| 150 | + $error = array($context->getI18n()->dt('client', $e->getMessage())); |
|
| 151 | + $view->pageErrorList = array_merge($view->get('pageErrorList', []), $error); |
|
| 152 | 152 | } |
| 153 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 153 | + catch (\Aimeos\Controller\Frontend\Exception $e) |
|
| 154 | 154 | { |
| 155 | - $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 156 | - $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
|
| 155 | + $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); |
|
| 156 | + $view->pageErrorList = array_merge($view->get('pageErrorList', []), $error); |
|
| 157 | 157 | } |
| 158 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 158 | + catch (\Aimeos\MShop\Exception $e) |
|
| 159 | 159 | { |
| 160 | - $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 161 | - $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
|
| 160 | + $error = array($context->getI18n()->dt('mshop', $e->getMessage())); |
|
| 161 | + $view->pageErrorList = array_merge($view->get('pageErrorList', []), $error); |
|
| 162 | 162 | } |
| 163 | - catch( \Exception $e ) |
|
| 163 | + catch (\Exception $e) |
|
| 164 | 164 | { |
| 165 | - $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
|
| 166 | - $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
|
| 167 | - $this->logException( $e ); |
|
| 165 | + $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured')); |
|
| 166 | + $view->pageErrorList = array_merge($view->get('pageErrorList', []), $error); |
|
| 167 | + $this->logException($e); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $html = $view->render( $view->config( $tplconf, $default ) ); |
|
| 170 | + $html = $view->render($view->config($tplconf, $default)); |
|
| 171 | 171 | } |
| 172 | 172 | else |
| 173 | 173 | { |
| 174 | - $html = $this->modifyBody( $html, $uid ); |
|
| 174 | + $html = $this->modifyBody($html, $uid); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | return $html; |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | * @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
| 185 | 185 | * @return string|null String including HTML tags for the header on error |
| 186 | 186 | */ |
| 187 | - public function getHeader( string $uid = '' ) : ?string |
|
| 187 | + public function getHeader(string $uid = '') : ?string |
|
| 188 | 188 | { |
| 189 | 189 | $prefixes = ['page']; |
| 190 | 190 | $confkey = 'client/html/cms/page'; |
| 191 | 191 | |
| 192 | - if( ( $html = $this->getCached( 'header', $uid, $prefixes, $confkey ) ) === null ) |
|
| 192 | + if (($html = $this->getCached('header', $uid, $prefixes, $confkey)) === null) |
|
| 193 | 193 | { |
| 194 | 194 | $view = $this->getView(); |
| 195 | 195 | |
@@ -221,28 +221,28 @@ discard block |
||
| 221 | 221 | { |
| 222 | 222 | $html = ''; |
| 223 | 223 | |
| 224 | - if( !isset( $this->view ) ) { |
|
| 225 | - $view = $this->view = $this->getObject()->addData( $view, $this->tags, $this->expire ); |
|
| 224 | + if (!isset($this->view)) { |
|
| 225 | + $view = $this->view = $this->getObject()->addData($view, $this->tags, $this->expire); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - foreach( $this->getSubClients() as $subclient ) { |
|
| 229 | - $html .= $subclient->setView( $view )->getHeader( $uid ); |
|
| 228 | + foreach ($this->getSubClients() as $subclient) { |
|
| 229 | + $html .= $subclient->setView($view)->getHeader($uid); |
|
| 230 | 230 | } |
| 231 | 231 | $view->pageHeader = $html; |
| 232 | 232 | |
| 233 | - $html = $view->render( $view->config( $tplconf, $default ) ); |
|
| 234 | - $this->setCached( 'header', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire ); |
|
| 233 | + $html = $view->render($view->config($tplconf, $default)); |
|
| 234 | + $this->setCached('header', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire); |
|
| 235 | 235 | |
| 236 | 236 | return $html; |
| 237 | 237 | } |
| 238 | - catch( \Exception $e ) |
|
| 238 | + catch (\Exception $e) |
|
| 239 | 239 | { |
| 240 | - $this->logException( $e ); |
|
| 240 | + $this->logException($e); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | else |
| 244 | 244 | { |
| 245 | - $html = $this->modifyHeader( $html, $uid ); |
|
| 245 | + $html = $this->modifyHeader($html, $uid); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | return $html; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @param string|null $name Name of the sub-client (Default if null) |
| 257 | 257 | * @return \Aimeos\Client\Html\Iface Sub-client object |
| 258 | 258 | */ |
| 259 | - public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface |
|
| 259 | + public function getSubClient(string $type, string $name = null) : \Aimeos\Client\Html\Iface |
|
| 260 | 260 | { |
| 261 | 261 | /** client/html/cms/page/decorators/excludes |
| 262 | 262 | * Excludes decorators added by the "common" option from the cms page html client |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @see client/html/cms/page/decorators/excludes |
| 332 | 332 | * @see client/html/cms/page/decorators/global |
| 333 | 333 | */ |
| 334 | - return $this->createSubClient( 'cms/page/' . $type, $name ); |
|
| 334 | + return $this->createSubClient('cms/page/' . $type, $name); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | |
@@ -350,26 +350,26 @@ discard block |
||
| 350 | 350 | { |
| 351 | 351 | parent::process(); |
| 352 | 352 | } |
| 353 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 353 | + catch (\Aimeos\Client\Html\Exception $e) |
|
| 354 | 354 | { |
| 355 | - $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
|
| 356 | - $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
|
| 355 | + $error = array($context->getI18n()->dt('client', $e->getMessage())); |
|
| 356 | + $view->pageErrorList = array_merge($view->get('pageErrorList', []), $error); |
|
| 357 | 357 | } |
| 358 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 358 | + catch (\Aimeos\Controller\Frontend\Exception $e) |
|
| 359 | 359 | { |
| 360 | - $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
|
| 361 | - $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
|
| 360 | + $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); |
|
| 361 | + $view->pageErrorList = array_merge($view->get('pageErrorList', []), $error); |
|
| 362 | 362 | } |
| 363 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 363 | + catch (\Aimeos\MShop\Exception $e) |
|
| 364 | 364 | { |
| 365 | - $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
|
| 366 | - $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
|
| 365 | + $error = array($context->getI18n()->dt('mshop', $e->getMessage())); |
|
| 366 | + $view->pageErrorList = array_merge($view->get('pageErrorList', []), $error); |
|
| 367 | 367 | } |
| 368 | - catch( \Exception $e ) |
|
| 368 | + catch (\Exception $e) |
|
| 369 | 369 | { |
| 370 | - $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
|
| 371 | - $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
|
| 372 | - $this->logException( $e ); |
|
| 370 | + $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured')); |
|
| 371 | + $view->pageErrorList = array_merge($view->get('pageErrorList', []), $error); |
|
| 372 | + $this->logException($e); |
|
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | protected function getSubClientNames() : array |
| 383 | 383 | { |
| 384 | - return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
| 384 | + return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | |
@@ -393,10 +393,10 @@ discard block |
||
| 393 | 393 | * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
| 394 | 394 | * @return \Aimeos\MW\View\Iface Modified view object |
| 395 | 395 | */ |
| 396 | - public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface |
|
| 396 | + public function addData(\Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null) : \Aimeos\MW\View\Iface |
|
| 397 | 397 | { |
| 398 | 398 | $context = $this->getContext(); |
| 399 | - $controller = \Aimeos\Controller\Frontend::create( $context, 'cms' ); |
|
| 399 | + $controller = \Aimeos\Controller\Frontend::create($context, 'cms'); |
|
| 400 | 400 | |
| 401 | 401 | /** client/html/cms/page/domains |
| 402 | 402 | * A list of domain names whose items should be available in the cms page view template |
@@ -411,14 +411,14 @@ discard block |
||
| 411 | 411 | * @param array List of domain names |
| 412 | 412 | * @since 2021.04 |
| 413 | 413 | */ |
| 414 | - $domains = $context->getConfig()->get( 'client/html/cms/page/domains', ['media', 'text'] ); |
|
| 414 | + $domains = $context->getConfig()->get('client/html/cms/page/domains', ['media', 'text']); |
|
| 415 | 415 | |
| 416 | - $page = $controller->uses( $domains )->find( $view->param( 'path', '/' ) ); |
|
| 416 | + $page = $controller->uses($domains)->find($view->param('path', '/')); |
|
| 417 | 417 | |
| 418 | - $this->addMetaItems( $page, $expire, $tags ); |
|
| 418 | + $this->addMetaItems($page, $expire, $tags); |
|
| 419 | 419 | |
| 420 | 420 | $view->pageCmsItem = $page; |
| 421 | 421 | |
| 422 | - return parent::addData( $view, $tags, $expire ); |
|
| 422 | + return parent::addData($view, $tags, $expire); |
|
| 423 | 423 | } |
| 424 | 424 | } |
@@ -144,23 +144,19 @@ discard block |
||
| 144 | 144 | $this->setCached( 'body', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire ); |
| 145 | 145 | |
| 146 | 146 | return $html; |
| 147 | - } |
|
| 148 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 147 | + } catch( \Aimeos\Client\Html\Exception $e ) |
|
| 149 | 148 | { |
| 150 | 149 | $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
| 151 | 150 | $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
| 152 | - } |
|
| 153 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 151 | + } catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 154 | 152 | { |
| 155 | 153 | $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
| 156 | 154 | $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
| 157 | - } |
|
| 158 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 155 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 159 | 156 | { |
| 160 | 157 | $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
| 161 | 158 | $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
| 162 | - } |
|
| 163 | - catch( \Exception $e ) |
|
| 159 | + } catch( \Exception $e ) |
|
| 164 | 160 | { |
| 165 | 161 | $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
| 166 | 162 | $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
@@ -168,8 +164,7 @@ discard block |
||
| 168 | 164 | } |
| 169 | 165 | |
| 170 | 166 | $html = $view->render( $view->config( $tplconf, $default ) ); |
| 171 | - } |
|
| 172 | - else |
|
| 167 | + } else |
|
| 173 | 168 | { |
| 174 | 169 | $html = $this->modifyBody( $html, $uid ); |
| 175 | 170 | } |
@@ -234,13 +229,11 @@ discard block |
||
| 234 | 229 | $this->setCached( 'header', $uid, $prefixes, $confkey, $html, $this->tags, $this->expire ); |
| 235 | 230 | |
| 236 | 231 | return $html; |
| 237 | - } |
|
| 238 | - catch( \Exception $e ) |
|
| 232 | + } catch( \Exception $e ) |
|
| 239 | 233 | { |
| 240 | 234 | $this->logException( $e ); |
| 241 | 235 | } |
| 242 | - } |
|
| 243 | - else |
|
| 236 | + } else |
|
| 244 | 237 | { |
| 245 | 238 | $html = $this->modifyHeader( $html, $uid ); |
| 246 | 239 | } |
@@ -349,23 +342,19 @@ discard block |
||
| 349 | 342 | try |
| 350 | 343 | { |
| 351 | 344 | parent::process(); |
| 352 | - } |
|
| 353 | - catch( \Aimeos\Client\Html\Exception $e ) |
|
| 345 | + } catch( \Aimeos\Client\Html\Exception $e ) |
|
| 354 | 346 | { |
| 355 | 347 | $error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) ); |
| 356 | 348 | $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
| 357 | - } |
|
| 358 | - catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 349 | + } catch( \Aimeos\Controller\Frontend\Exception $e ) |
|
| 359 | 350 | { |
| 360 | 351 | $error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) ); |
| 361 | 352 | $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
| 362 | - } |
|
| 363 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 353 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 364 | 354 | { |
| 365 | 355 | $error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
| 366 | 356 | $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
| 367 | - } |
|
| 368 | - catch( \Exception $e ) |
|
| 357 | + } catch( \Exception $e ) |
|
| 369 | 358 | { |
| 370 | 359 | $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) ); |
| 371 | 360 | $view->pageErrorList = array_merge( $view->get( 'pageErrorList', [] ), $error ); |
@@ -7,10 +7,10 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | $enc = $this->encoder(); |
| 9 | 9 | |
| 10 | -$target = $this->config( 'client/html/cms/page/url/target' ); |
|
| 11 | -$cntl = $this->config( 'client/html/cms/page/url/controller', 'cms' ); |
|
| 12 | -$action = $this->config( 'client/html/cms/page/url/action', 'page' ); |
|
| 13 | -$config = $this->config( 'client/html/cms/page/url/config', [] ); |
|
| 10 | +$target = $this->config('client/html/cms/page/url/target'); |
|
| 11 | +$cntl = $this->config('client/html/cms/page/url/controller', 'cms'); |
|
| 12 | +$action = $this->config('client/html/cms/page/url/action', 'page'); |
|
| 13 | +$config = $this->config('client/html/cms/page/url/config', []); |
|
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | /** client/html/cms/page/metatags |
@@ -32,30 +32,30 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | ?> |
| 35 | -<?php if( (bool) $this->config( 'client/html/cms/page/metatags', true ) === true ) : ?> |
|
| 36 | - <?php if( isset( $this->pageCmsItem ) ) : ?> |
|
| 37 | - <title><?= $enc->html( $this->pageCmsItem->getName() ); ?></title> |
|
| 35 | +<?php if ((bool) $this->config('client/html/cms/page/metatags', true) === true) : ?> |
|
| 36 | + <?php if (isset($this->pageCmsItem)) : ?> |
|
| 37 | + <title><?= $enc->html($this->pageCmsItem->getName()); ?></title> |
|
| 38 | 38 | |
| 39 | - <?php foreach( $this->pageCmsItem->getRefItems( 'text', 'meta-keyword', 'default' ) as $textItem ) : ?> |
|
| 40 | - <meta name="keywords" content="<?= $enc->attr( strip_tags( $textItem->getContent() ) ); ?>" /> |
|
| 39 | + <?php foreach ($this->pageCmsItem->getRefItems('text', 'meta-keyword', 'default') as $textItem) : ?> |
|
| 40 | + <meta name="keywords" content="<?= $enc->attr(strip_tags($textItem->getContent())); ?>" /> |
|
| 41 | 41 | <?php endforeach; ?> |
| 42 | 42 | |
| 43 | - <?php foreach( $this->pageCmsItem->getRefItems( 'text', 'meta-description', 'default' ) as $textItem ) : ?> |
|
| 44 | - <meta name="description" content="<?= $enc->attr( strip_tags( $textItem->getContent() ) ); ?>" /> |
|
| 43 | + <?php foreach ($this->pageCmsItem->getRefItems('text', 'meta-description', 'default') as $textItem) : ?> |
|
| 44 | + <meta name="description" content="<?= $enc->attr(strip_tags($textItem->getContent())); ?>" /> |
|
| 45 | 45 | <?php endforeach; ?> |
| 46 | 46 | |
| 47 | - <link rel="canonical" href="<?= $enc->attr( $this->url( $target, $cntl, $action, ['path' => $this->pageCmsItem->getUrl()], $config + ['absoluteUri' => true] ) ); ?>" /> |
|
| 47 | + <link rel="canonical" href="<?= $enc->attr($this->url($target, $cntl, $action, ['path' => $this->pageCmsItem->getUrl()], $config + ['absoluteUri' => true])); ?>" /> |
|
| 48 | 48 | |
| 49 | 49 | <meta property="og:type" content="article" /> |
| 50 | - <meta property="og:title" content="<?= $enc->html( $this->pageCmsItem->getName() ); ?>" /> |
|
| 51 | - <meta property="og:url" content="<?= $enc->attr( $this->url( $target, $cntl, $action, ['path' => $this->pageCmsItem->getUrl()], $config + ['absoluteUri' => true] ) ); ?>" /> |
|
| 50 | + <meta property="og:title" content="<?= $enc->html($this->pageCmsItem->getName()); ?>" /> |
|
| 51 | + <meta property="og:url" content="<?= $enc->attr($this->url($target, $cntl, $action, ['path' => $this->pageCmsItem->getUrl()], $config + ['absoluteUri' => true])); ?>" /> |
|
| 52 | 52 | |
| 53 | - <?php foreach( $this->pageCmsItem->getRefItems( 'text', 'short', 'default' ) as $textItem ) : ?> |
|
| 54 | - <meta property="og:description" content="<?= $enc->attr( $textItem->getContent() ) ?>" /> |
|
| 53 | + <?php foreach ($this->pageCmsItem->getRefItems('text', 'short', 'default') as $textItem) : ?> |
|
| 54 | + <meta property="og:description" content="<?= $enc->attr($textItem->getContent()) ?>" /> |
|
| 55 | 55 | <?php endforeach ?> |
| 56 | 56 | |
| 57 | - <?php foreach( $this->pageCmsItem->getRefItems( 'media', 'default', 'default' ) as $mediaItem ) : ?> |
|
| 58 | - <meta property="og:image" content="<?= $enc->attr( $this->content( $mediaItem->getUrl() ) ) ?>" /> |
|
| 57 | + <?php foreach ($this->pageCmsItem->getRefItems('media', 'default', 'default') as $mediaItem) : ?> |
|
| 58 | + <meta property="og:image" content="<?= $enc->attr($this->content($mediaItem->getUrl())) ?>" /> |
|
| 59 | 59 | <?php endforeach ?> |
| 60 | 60 | |
| 61 | 61 | <meta name="twitter:card" content="summary_large_image" /> |
@@ -65,4 +65,4 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | <?php endif; ?> |
| 67 | 67 | |
| 68 | -<?= $this->get( 'pageHeader' ); ?> |
|
| 68 | +<?= $this->get('pageHeader'); ?> |
|
@@ -14,18 +14,18 @@ |
||
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | ?> |
| 17 | -<section class="aimeos cms-page" data-jsonurl="<?= $enc->attr( $this->link( 'client/jsonapi/url' ) ); ?>"> |
|
| 17 | +<section class="aimeos cms-page" data-jsonurl="<?= $enc->attr($this->link('client/jsonapi/url')); ?>"> |
|
| 18 | 18 | |
| 19 | - <?php if( isset( $this->pageErrorList ) ) : ?> |
|
| 19 | + <?php if (isset($this->pageErrorList)) : ?> |
|
| 20 | 20 | <ul class="error-list"> |
| 21 | - <?php foreach( (array) $this->pageErrorList as $errmsg ) : ?> |
|
| 22 | - <li class="error-item"><?= $enc->html( $errmsg ); ?></li> |
|
| 21 | + <?php foreach ((array) $this->pageErrorList as $errmsg) : ?> |
|
| 22 | + <li class="error-item"><?= $enc->html($errmsg); ?></li> |
|
| 23 | 23 | <?php endforeach; ?> |
| 24 | 24 | </ul> |
| 25 | 25 | <?php endif; ?> |
| 26 | 26 | |
| 27 | - <?php if( isset( $this->pageCmsItem ) ) : ?> |
|
| 28 | - <?php foreach( $this->pageCmsItem->getRefItems( 'text', 'content' ) as $textItem ) : ?> |
|
| 27 | + <?php if (isset($this->pageCmsItem)) : ?> |
|
| 28 | + <?php foreach ($this->pageCmsItem->getRefItems('text', 'content') as $textItem) : ?> |
|
| 29 | 29 | <?= $textItem->getContent() ?> |
| 30 | 30 | <?php endforeach ?> |
| 31 | 31 | <?php endif; ?> |
@@ -22,35 +22,35 @@ |
||
| 22 | 22 | |
| 23 | 23 | protected function tearDown() : void |
| 24 | 24 | { |
| 25 | - unset( $this->context ); |
|
| 25 | + unset($this->context); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | public function testCreateClient() |
| 30 | 30 | { |
| 31 | - $client = \Aimeos\Client\Html\Cms\Page\Factory::create( $this->context ); |
|
| 32 | - $this->assertInstanceOf( '\\Aimeos\\Client\\Html\\Iface', $client ); |
|
| 31 | + $client = \Aimeos\Client\Html\Cms\Page\Factory::create($this->context); |
|
| 32 | + $this->assertInstanceOf('\\Aimeos\\Client\\Html\\Iface', $client); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | public function testCreateClientName() |
| 37 | 37 | { |
| 38 | - $client = \Aimeos\Client\Html\Cms\Page\Factory::create( $this->context, 'Standard' ); |
|
| 39 | - $this->assertInstanceOf( '\\Aimeos\\Client\\Html\\Iface', $client ); |
|
| 38 | + $client = \Aimeos\Client\Html\Cms\Page\Factory::create($this->context, 'Standard'); |
|
| 39 | + $this->assertInstanceOf('\\Aimeos\\Client\\Html\\Iface', $client); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | public function testCreateClientNameInvalid() |
| 44 | 44 | { |
| 45 | - $this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
|
| 46 | - \Aimeos\Client\Html\Cms\Page\Factory::create( $this->context, '$$$' ); |
|
| 45 | + $this->expectException('\\Aimeos\\Client\\Html\\Exception'); |
|
| 46 | + \Aimeos\Client\Html\Cms\Page\Factory::create($this->context, '$$$'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | public function testCreateClientNameNotFound() |
| 51 | 51 | { |
| 52 | - $this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
|
| 53 | - \Aimeos\Client\Html\Cms\Page\Factory::create( $this->context, 'notfound' ); |
|
| 52 | + $this->expectException('\\Aimeos\\Client\\Html\\Exception'); |
|
| 53 | + \Aimeos\Client\Html\Cms\Page\Factory::create($this->context, 'notfound'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | } |