@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
| 34 | 34 | * @param string $path Path describing the client to clear, e.g. "product/lists/type" |
| 35 | 35 | */ |
| 36 | - static public function clear( $id = null, $path = null ) |
|
| 36 | + static public function clear($id = null, $path = null) |
|
| 37 | 37 | { |
| 38 | - if( $id !== null ) |
|
| 38 | + if ($id !== null) |
|
| 39 | 39 | { |
| 40 | - if( $path !== null ) { |
|
| 40 | + if ($path !== null) { |
|
| 41 | 41 | self::$clients[$id][$path] = null; |
| 42 | 42 | } else { |
| 43 | 43 | self::$clients[$id] = array(); |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
| 66 | 66 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
| 67 | 67 | */ |
| 68 | - static public function createClient( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 69 | - array $templatePaths, $path, $name = null ) |
|
| 68 | + static public function createClient(\Aimeos\MShop\Context\Item\Iface $context, |
|
| 69 | + array $templatePaths, $path, $name = null) |
|
| 70 | 70 | { |
| 71 | - $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); |
|
| 71 | + $path = strtolower(trim($path, "/ \n\t\r\0\x0B")); |
|
| 72 | 72 | |
| 73 | - if( empty( $path ) ) { |
|
| 74 | - return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name ); |
|
| 73 | + if (empty($path)) { |
|
| 74 | + return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $id = (string) $context; |
| 78 | 78 | |
| 79 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) { |
|
| 80 | - self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name ); |
|
| 79 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) { |
|
| 80 | + self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | return self::$clients[$id][$path]; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param boolean $value True to enable caching, false to disable it. |
| 91 | 91 | * @return boolean Previous cache setting |
| 92 | 92 | */ |
| 93 | - static public function setCache( $value ) |
|
| 93 | + static public function setCache($value) |
|
| 94 | 94 | { |
| 95 | 95 | $old = self::$cache; |
| 96 | 96 | self::$cache = (boolean) $value; |
@@ -109,37 +109,37 @@ discard block |
||
| 109 | 109 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
| 110 | 110 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
| 111 | 111 | */ |
| 112 | - protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 113 | - array $templatePaths, $path, $name ) |
|
| 112 | + protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context, |
|
| 113 | + array $templatePaths, $path, $name) |
|
| 114 | 114 | { |
| 115 | - $parts = explode( '/', $path ); |
|
| 115 | + $parts = explode('/', $path); |
|
| 116 | 116 | |
| 117 | - foreach( $parts as $key => $part ) |
|
| 117 | + foreach ($parts as $key => $part) |
|
| 118 | 118 | { |
| 119 | - if( ctype_alnum( $part ) === false ) |
|
| 119 | + if (ctype_alnum($part) === false) |
|
| 120 | 120 | { |
| 121 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
| 122 | - throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 ); |
|
| 121 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
| 122 | + throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $parts[$key] = ucwords( $part ); |
|
| 125 | + $parts[$key] = ucwords($part); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | $view = $context->getView(); |
| 130 | - $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\Factory'; |
|
| 130 | + $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\Factory'; |
|
| 131 | 131 | |
| 132 | - if( class_exists( $factory ) === true ) |
|
| 132 | + if (class_exists($factory) === true) |
|
| 133 | 133 | { |
| 134 | - $args = array( $context, $view, $templatePaths, $path, $name ); |
|
| 134 | + $args = array($context, $view, $templatePaths, $path, $name); |
|
| 135 | 135 | |
| 136 | - if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
|
| 137 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
|
| 136 | + if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) { |
|
| 137 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid factory "%1$s"', $factory), 400); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | else |
| 141 | 141 | { |
| 142 | - $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
|
| 142 | + $client = self::createClientRoot($context, $view, $templatePaths, $path, $name); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | return $client; |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
| 158 | 158 | * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created |
| 159 | 159 | */ |
| 160 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 161 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null ) |
|
| 160 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
| 161 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) |
|
| 162 | 162 | { |
| 163 | 163 | /** admin/jsonadm/name |
| 164 | 164 | * Class name of the used JSON API client implementation |
@@ -193,20 +193,20 @@ discard block |
||
| 193 | 193 | * @since 2015.12 |
| 194 | 194 | * @category Developer |
| 195 | 195 | */ |
| 196 | - if( $name === null ) { |
|
| 197 | - $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
|
| 196 | + if ($name === null) { |
|
| 197 | + $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if( ctype_alnum( $name ) === false ) |
|
| 200 | + if (ctype_alnum($name) === false) |
|
| 201 | 201 | { |
| 202 | - $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
| 203 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
| 202 | + $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
| 203 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
| 207 | 207 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
| 208 | 208 | |
| 209 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
| 209 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
| 210 | 210 | |
| 211 | 211 | /** admin/jsonadm/decorators/excludes |
| 212 | 212 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -286,6 +286,6 @@ discard block |
||
| 286 | 286 | * @see admin/jsonadm/decorators/global |
| 287 | 287 | */ |
| 288 | 288 | |
| 289 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
| 289 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
| 290 | 290 | } |
| 291 | 291 | } |
@@ -136,8 +136,7 @@ |
||
| 136 | 136 | if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
| 137 | 137 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
| 138 | 138 | } |
| 139 | - } |
|
| 140 | - else |
|
| 139 | + } else |
|
| 141 | 140 | { |
| 142 | 141 | $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
| 143 | 142 | } |
@@ -19,77 +19,77 @@ discard block |
||
| 19 | 19 | $this->context = \TestHelperJadm::getContext(); |
| 20 | 20 | $config = $this->context->getConfig(); |
| 21 | 21 | |
| 22 | - $config->set( 'admin/jsonadm/common/decorators/default', array() ); |
|
| 23 | - $config->set( 'admin/jsonadm/decorators/global', array() ); |
|
| 24 | - $config->set( 'admin/jsonadm/decorators/local', array() ); |
|
| 22 | + $config->set('admin/jsonadm/common/decorators/default', array()); |
|
| 23 | + $config->set('admin/jsonadm/decorators/global', array()); |
|
| 24 | + $config->set('admin/jsonadm/decorators/local', array()); |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | public function testInjectClient() |
| 30 | 30 | { |
| 31 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
| 32 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
| 31 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
| 32 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
| 33 | 33 | |
| 34 | - $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
| 34 | + $iCntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
| 35 | 35 | |
| 36 | - $this->assertSame( $cntl, $iCntl ); |
|
| 36 | + $this->assertSame($cntl, $iCntl); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | public function testInjectClientReset() |
| 41 | 41 | { |
| 42 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
| 43 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl ); |
|
| 44 | - \Aimeos\Admin\JsonAdm\Factory::injectClient( '\\Aimeos\\Admin\\JsonAdm\\Standard', null ); |
|
| 42 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
| 43 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', $cntl); |
|
| 44 | + \Aimeos\Admin\JsonAdm\Factory::injectClient('\\Aimeos\\Admin\\JsonAdm\\Standard', null); |
|
| 45 | 45 | |
| 46 | - $new = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
| 46 | + $new = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
| 47 | 47 | |
| 48 | - $this->assertNotSame( $cntl, $new ); |
|
| 48 | + $this->assertNotSame($cntl, $new); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | public function testAddDecoratorsInvalidName() |
| 53 | 53 | { |
| 54 | - $decorators = array( '$' ); |
|
| 54 | + $decorators = array('$'); |
|
| 55 | 55 | $view = $this->context->getView(); |
| 56 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
| 56 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
| 57 | 57 | |
| 58 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
| 59 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute' ); |
|
| 58 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
| 59 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'Test', $this->context, $view, array(), 'attribute'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | public function testAddDecoratorsInvalidClass() |
| 64 | 64 | { |
| 65 | - $decorators = array( 'Test' ); |
|
| 65 | + $decorators = array('Test'); |
|
| 66 | 66 | $view = $this->context->getView(); |
| 67 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
| 67 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
| 68 | 68 | |
| 69 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
| 70 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute' ); |
|
| 69 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
| 70 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, 'TestDecorator', $this->context, $view, array(), 'attribute'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | public function testAddDecoratorsInvalidInterface() |
| 75 | 75 | { |
| 76 | - $decorators = array( 'Test' ); |
|
| 76 | + $decorators = array('Test'); |
|
| 77 | 77 | $view = $this->context->getView(); |
| 78 | - $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
| 78 | + $cntl = \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
| 79 | 79 | |
| 80 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
| 81 | - \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic( $cntl, $decorators, |
|
| 82 | - '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute' ); |
|
| 80 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
| 81 | + \Aimeos\Admin\JsonAdm\Common\Factory\TestAbstract::addDecoratorsPublic($cntl, $decorators, |
|
| 82 | + '\\Aimeos\\Admin\\Jsonadm\\Common\\Decorator\\', $this->context, $view, array(), 'attribute'); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | public function testAddClientDecoratorsExcludes() |
| 87 | 87 | { |
| 88 | - $this->context->getConfig()->set( 'admin/jsonadm/decorators/excludes', array( 'TestDecorator' ) ); |
|
| 89 | - $this->context->getConfig()->set( 'admin/jsonadm/common/decorators/default', array( 'TestDecorator' ) ); |
|
| 88 | + $this->context->getConfig()->set('admin/jsonadm/decorators/excludes', array('TestDecorator')); |
|
| 89 | + $this->context->getConfig()->set('admin/jsonadm/common/decorators/default', array('TestDecorator')); |
|
| 90 | 90 | |
| 91 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
| 92 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $this->context, array(), 'attribute', 'Standard' ); |
|
| 91 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
| 92 | + \Aimeos\Admin\JsonAdm\Factory::createClient($this->context, array(), 'attribute', 'Standard'); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | * @param string $classprefix |
| 102 | 102 | * @param string $path |
| 103 | 103 | */ |
| 104 | - public static function addDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
| 105 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
| 104 | + public static function addDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix, |
|
| 105 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
| 106 | 106 | { |
| 107 | - self::addDecorators( $client, $decorators, $classprefix, $context, $view, $templatePaths, $path ); |
|
| 107 | + self::addDecorators($client, $decorators, $classprefix, $context, $view, $templatePaths, $path); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public static function addClientDecoratorsPublic( \Aimeos\Admin\JsonAdm\Iface $client, |
|
| 111 | - \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path ) |
|
| 110 | + public static function addClientDecoratorsPublic(\Aimeos\Admin\JsonAdm\Iface $client, |
|
| 111 | + \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, $templatePaths, $path) |
|
| 112 | 112 | { |
| 113 | - self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
| 113 | + self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 23 | 23 | $this->view = $this->context->getView(); |
| 24 | 24 | |
| 25 | - $this->object = new \Aimeos\Admin\JsonAdm\Product\Standard( $this->context, $this->view, $templatePaths, 'product' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Product\Standard($this->context, $this->view, $templatePaths, 'product'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,34 +30,34 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | 32 | 'filter' => array( |
| 33 | - '==' => array( 'product.code' => 'CNE' ) |
|
| 33 | + '==' => array('product.code' => 'CNE') |
|
| 34 | 34 | ), |
| 35 | 35 | 'include' => 'text,product,product/property,product/stock' |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | 40 | $header = array(); |
| 41 | 41 | $status = 500; |
| 42 | 42 | |
| 43 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 44 | - |
|
| 45 | - $this->assertEquals( 200, $status ); |
|
| 46 | - $this->assertEquals( 1, count( $header ) ); |
|
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 49 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 50 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) ); |
|
| 51 | - $this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['text'][0]['data']['links'] ); |
|
| 52 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['product'] ) ); |
|
| 53 | - $this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['product'][0]['data']['links'] ); |
|
| 54 | - $this->assertEquals( 4, count( $result['data'][0]['relationships']['product/property'] ) ); |
|
| 55 | - $this->assertEquals( 1, count( $result['data'][0]['relationships']['product/stock'] ) ); |
|
| 56 | - $this->assertEquals( 15, count( $result['included'] ) ); |
|
| 57 | - $this->assertEquals( 'product/property', $result['included'][0]['type'] ); |
|
| 58 | - $this->assertArrayHaskey( 'self', $result['included'][0]['links'] ); |
|
| 59 | - $this->assertArrayHaskey( 'related', $result['included'][0]['links'] ); |
|
| 60 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 43 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 44 | + |
|
| 45 | + $this->assertEquals(200, $status); |
|
| 46 | + $this->assertEquals(1, count($header)); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals(1, count($result['data'])); |
|
| 49 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 50 | + $this->assertEquals(6, count($result['data'][0]['relationships']['text'])); |
|
| 51 | + $this->assertArrayHaskey('self', $result['data'][0]['relationships']['text'][0]['data']['links']); |
|
| 52 | + $this->assertEquals(5, count($result['data'][0]['relationships']['product'])); |
|
| 53 | + $this->assertArrayHaskey('self', $result['data'][0]['relationships']['product'][0]['data']['links']); |
|
| 54 | + $this->assertEquals(4, count($result['data'][0]['relationships']['product/property'])); |
|
| 55 | + $this->assertEquals(1, count($result['data'][0]['relationships']['product/stock'])); |
|
| 56 | + $this->assertEquals(15, count($result['included'])); |
|
| 57 | + $this->assertEquals('product/property', $result['included'][0]['type']); |
|
| 58 | + $this->assertArrayHaskey('self', $result['included'][0]['links']); |
|
| 59 | + $this->assertArrayHaskey('related', $result['included'][0]['links']); |
|
| 60 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -70,22 +70,22 @@ discard block |
||
| 70 | 70 | 'sort' => 'product.id', |
| 71 | 71 | 'include' => 'product,product/stock' |
| 72 | 72 | ); |
| 73 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 74 | - $this->view->addHelper( 'param', $helper ); |
|
| 73 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 74 | + $this->view->addHelper('param', $helper); |
|
| 75 | 75 | |
| 76 | 76 | $header = array(); |
| 77 | 77 | $status = 500; |
| 78 | 78 | |
| 79 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 80 | - |
|
| 81 | - $this->assertEquals( 200, $status ); |
|
| 82 | - $this->assertEquals( 1, count( $header ) ); |
|
| 83 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
| 84 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
| 85 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 86 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
| 87 | - $this->assertEquals( 5, count( $result['data'][0]['relationships']['product'] ) ); |
|
| 88 | - $this->assertEquals( 27, count( $result['included'] ) ); |
|
| 89 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 79 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 80 | + |
|
| 81 | + $this->assertEquals(200, $status); |
|
| 82 | + $this->assertEquals(1, count($header)); |
|
| 83 | + $this->assertEquals(28, $result['meta']['total']); |
|
| 84 | + $this->assertEquals(25, count($result['data'])); |
|
| 85 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 86 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
| 87 | + $this->assertEquals(5, count($result['data'][0]['relationships']['product'])); |
|
| 88 | + $this->assertEquals(27, count($result['included'])); |
|
| 89 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | \ No newline at end of file |
@@ -49,6 +49,7 @@ discard block |
||
| 49 | 49 | * @param string $body Request body |
| 50 | 50 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
| 51 | 51 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 52 | + * @param integer $status |
|
| 52 | 53 | * @return string Content for response body |
| 53 | 54 | */ |
| 54 | 55 | public function delete( $body, array &$header, &$status ) |
@@ -252,6 +253,7 @@ discard block |
||
| 252 | 253 | * @param string $body Request body |
| 253 | 254 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
| 254 | 255 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 256 | + * @param integer $status |
|
| 255 | 257 | * @return string Content for response body |
| 256 | 258 | */ |
| 257 | 259 | public function patch( $body, array &$header, &$status ) |
@@ -380,6 +382,7 @@ discard block |
||
| 380 | 382 | * @param string $body Request body |
| 381 | 383 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
| 382 | 384 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 385 | + * @param integer $status |
|
| 383 | 386 | * @return string Content for response body |
| 384 | 387 | */ |
| 385 | 388 | public function post( $body, array &$header, &$status ) |
@@ -508,6 +511,7 @@ discard block |
||
| 508 | 511 | * @param string $body Request body |
| 509 | 512 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
| 510 | 513 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 514 | + * @param integer $status |
|
| 511 | 515 | * @return string Content for response body |
| 512 | 516 | */ |
| 513 | 517 | public function put( $body, array &$header, &$status ) |
@@ -559,6 +563,7 @@ discard block |
||
| 559 | 563 | * @param string $body Request body |
| 560 | 564 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
| 561 | 565 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 566 | + * @param integer $status |
|
| 562 | 567 | * @return string Content for response body |
| 563 | 568 | */ |
| 564 | 569 | public function options( $body, array &$header, &$status ) |
@@ -29,39 +29,39 @@ discard block |
||
| 29 | 29 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 30 | 30 | * @return string Content for response body |
| 31 | 31 | */ |
| 32 | - public function delete( $body, array &$header, &$status ) |
|
| 32 | + public function delete($body, array &$header, &$status) |
|
| 33 | 33 | { |
| 34 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 34 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 35 | 35 | $view = $this->getView(); |
| 36 | 36 | |
| 37 | 37 | try |
| 38 | 38 | { |
| 39 | - $view = $this->deleteItems( $view, $body ); |
|
| 39 | + $view = $this->deleteItems($view, $body); |
|
| 40 | 40 | $status = 200; |
| 41 | 41 | } |
| 42 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 42 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 43 | 43 | { |
| 44 | 44 | $status = $e->getCode(); |
| 45 | - $view->errors = array( array( |
|
| 46 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 45 | + $view->errors = array(array( |
|
| 46 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 47 | 47 | 'detail' => $e->getTraceAsString(), |
| 48 | - ) ); |
|
| 48 | + )); |
|
| 49 | 49 | } |
| 50 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 50 | + catch (\Aimeos\MShop\Exception $e) |
|
| 51 | 51 | { |
| 52 | 52 | $status = 404; |
| 53 | - $view->errors = array( array( |
|
| 54 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 53 | + $view->errors = array(array( |
|
| 54 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 55 | 55 | 'detail' => $e->getTraceAsString(), |
| 56 | - ) ); |
|
| 56 | + )); |
|
| 57 | 57 | } |
| 58 | - catch( \Exception $e ) |
|
| 58 | + catch (\Exception $e) |
|
| 59 | 59 | { |
| 60 | 60 | $status = 500; |
| 61 | - $view->errors = array( array( |
|
| 61 | + $view->errors = array(array( |
|
| 62 | 62 | 'title' => $e->getMessage(), |
| 63 | 63 | 'detail' => $e->getTraceAsString(), |
| 64 | - ) ); |
|
| 64 | + )); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** admin/jsonadm/standard/template-delete |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
| 93 | 93 | $default = 'delete-default.php'; |
| 94 | 94 | |
| 95 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 95 | + return $view->render($view->config($tplconf, $default)); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
@@ -104,41 +104,41 @@ discard block |
||
| 104 | 104 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 105 | 105 | * @return string Content for response body |
| 106 | 106 | */ |
| 107 | - public function get( $body, array &$header, &$status ) |
|
| 107 | + public function get($body, array &$header, &$status) |
|
| 108 | 108 | { |
| 109 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 109 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 110 | 110 | |
| 111 | 111 | $view = $this->getView(); |
| 112 | - $aggregate = $view->param( 'aggregate' ); |
|
| 112 | + $aggregate = $view->param('aggregate'); |
|
| 113 | 113 | |
| 114 | 114 | try |
| 115 | 115 | { |
| 116 | - if( $aggregate !== null ) { |
|
| 117 | - $view = $this->getAggregate( $view ); |
|
| 116 | + if ($aggregate !== null) { |
|
| 117 | + $view = $this->getAggregate($view); |
|
| 118 | 118 | } else { |
| 119 | - $view = $this->getItems( $view ); |
|
| 119 | + $view = $this->getItems($view); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $status = 200; |
| 123 | 123 | } |
| 124 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 124 | + catch (\Aimeos\MShop\Exception $e) |
|
| 125 | 125 | { |
| 126 | 126 | $status = 404; |
| 127 | - $view->errors = array( array( |
|
| 128 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 127 | + $view->errors = array(array( |
|
| 128 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 129 | 129 | 'detail' => $e->getTraceAsString(), |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | } |
| 132 | - catch( \Exception $e ) |
|
| 132 | + catch (\Exception $e) |
|
| 133 | 133 | { |
| 134 | 134 | $status = 500; |
| 135 | - $view->errors = array( array( |
|
| 135 | + $view->errors = array(array( |
|
| 136 | 136 | 'title' => $e->getMessage(), |
| 137 | 137 | 'detail' => $e->getTraceAsString(), |
| 138 | - ) ); |
|
| 138 | + )); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if( $aggregate !== null ) |
|
| 141 | + if ($aggregate !== null) |
|
| 142 | 142 | { |
| 143 | 143 | /** admin/jsonadm/standard/template-aggregate |
| 144 | 144 | * Relative path to the JSON API template for GET aggregate requests |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $default = 'get-default.php'; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 202 | + return $view->render($view->config($tplconf, $default)); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | |
@@ -211,39 +211,39 @@ discard block |
||
| 211 | 211 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 212 | 212 | * @return string Content for response body |
| 213 | 213 | */ |
| 214 | - public function patch( $body, array &$header, &$status ) |
|
| 214 | + public function patch($body, array &$header, &$status) |
|
| 215 | 215 | { |
| 216 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 216 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 217 | 217 | $view = $this->getView(); |
| 218 | 218 | |
| 219 | 219 | try |
| 220 | 220 | { |
| 221 | - $view = $this->patchItems( $view, $body, $header ); |
|
| 221 | + $view = $this->patchItems($view, $body, $header); |
|
| 222 | 222 | $status = 200; |
| 223 | 223 | } |
| 224 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 224 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 225 | 225 | { |
| 226 | 226 | $status = $e->getCode(); |
| 227 | - $view->errors = array( array( |
|
| 228 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 227 | + $view->errors = array(array( |
|
| 228 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 229 | 229 | 'detail' => $e->getTraceAsString(), |
| 230 | - ) ); |
|
| 230 | + )); |
|
| 231 | 231 | } |
| 232 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 232 | + catch (\Aimeos\MShop\Exception $e) |
|
| 233 | 233 | { |
| 234 | 234 | $status = 404; |
| 235 | - $view->errors = array( array( |
|
| 236 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 235 | + $view->errors = array(array( |
|
| 236 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 237 | 237 | 'detail' => $e->getTraceAsString(), |
| 238 | - ) ); |
|
| 238 | + )); |
|
| 239 | 239 | } |
| 240 | - catch( \Exception $e ) |
|
| 240 | + catch (\Exception $e) |
|
| 241 | 241 | { |
| 242 | 242 | $status = 500; |
| 243 | - $view->errors = array( array( |
|
| 243 | + $view->errors = array(array( |
|
| 244 | 244 | 'title' => $e->getMessage(), |
| 245 | 245 | 'detail' => $e->getTraceAsString(), |
| 246 | - ) ); |
|
| 246 | + )); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** admin/jsonadm/standard/template-patch |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
| 275 | 275 | $default = 'patch-default.php'; |
| 276 | 276 | |
| 277 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 277 | + return $view->render($view->config($tplconf, $default)); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
@@ -286,39 +286,39 @@ discard block |
||
| 286 | 286 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 287 | 287 | * @return string Content for response body |
| 288 | 288 | */ |
| 289 | - public function post( $body, array &$header, &$status ) |
|
| 289 | + public function post($body, array &$header, &$status) |
|
| 290 | 290 | { |
| 291 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 291 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 292 | 292 | $view = $this->getView(); |
| 293 | 293 | |
| 294 | 294 | try |
| 295 | 295 | { |
| 296 | - $view = $this->postItems( $view, $body, $header ); |
|
| 296 | + $view = $this->postItems($view, $body, $header); |
|
| 297 | 297 | $status = 201; |
| 298 | 298 | } |
| 299 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 299 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 300 | 300 | { |
| 301 | 301 | $status = $e->getCode(); |
| 302 | - $view->errors = array( array( |
|
| 303 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 302 | + $view->errors = array(array( |
|
| 303 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 304 | 304 | 'detail' => $e->getTraceAsString(), |
| 305 | - ) ); |
|
| 305 | + )); |
|
| 306 | 306 | } |
| 307 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 307 | + catch (\Aimeos\MShop\Exception $e) |
|
| 308 | 308 | { |
| 309 | 309 | $status = 404; |
| 310 | - $view->errors = array( array( |
|
| 311 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 310 | + $view->errors = array(array( |
|
| 311 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 312 | 312 | 'detail' => $e->getTraceAsString(), |
| 313 | - ) ); |
|
| 313 | + )); |
|
| 314 | 314 | } |
| 315 | - catch( \Exception $e ) |
|
| 315 | + catch (\Exception $e) |
|
| 316 | 316 | { |
| 317 | 317 | $status = 500; |
| 318 | - $view->errors = array( array( |
|
| 318 | + $view->errors = array(array( |
|
| 319 | 319 | 'title' => $e->getMessage(), |
| 320 | 320 | 'detail' => $e->getTraceAsString(), |
| 321 | - ) ); |
|
| 321 | + )); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** admin/jsonadm/standard/template-post |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $tplconf = 'admin/jsonadm/standard/template-post'; |
| 350 | 350 | $default = 'post-default.php'; |
| 351 | 351 | |
| 352 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 352 | + return $view->render($view->config($tplconf, $default)); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | |
@@ -361,15 +361,15 @@ discard block |
||
| 361 | 361 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 362 | 362 | * @return string Content for response body |
| 363 | 363 | */ |
| 364 | - public function put( $body, array &$header, &$status ) |
|
| 364 | + public function put($body, array &$header, &$status) |
|
| 365 | 365 | { |
| 366 | 366 | $status = 501; |
| 367 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 367 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 368 | 368 | $view = $this->getView(); |
| 369 | 369 | |
| 370 | - $view->errors = array( array( |
|
| 371 | - 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
| 372 | - ) ); |
|
| 370 | + $view->errors = array(array( |
|
| 371 | + 'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
| 372 | + )); |
|
| 373 | 373 | |
| 374 | 374 | /** admin/jsonadm/standard/template-put |
| 375 | 375 | * Relative path to the JSON API template for PUT requests |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $tplconf = 'admin/jsonadm/standard/template-put'; |
| 400 | 400 | $default = 'put-default.php'; |
| 401 | 401 | |
| 402 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 402 | + return $view->render($view->config($tplconf, $default)); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 412 | 412 | * @return string Content for response body |
| 413 | 413 | */ |
| 414 | - public function options( $body, array &$header, &$status ) |
|
| 414 | + public function options($body, array &$header, &$status) |
|
| 415 | 415 | { |
| 416 | 416 | $context = $this->getContext(); |
| 417 | 417 | $view = $this->getView(); |
@@ -420,11 +420,11 @@ discard block |
||
| 420 | 420 | { |
| 421 | 421 | $resources = $attributes = array(); |
| 422 | 422 | |
| 423 | - foreach( $this->getDomains( $view ) as $domain ) |
|
| 423 | + foreach ($this->getDomains($view) as $domain) |
|
| 424 | 424 | { |
| 425 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
| 426 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
| 427 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
| 425 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
| 426 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
| 427 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | $view->resources = $resources; |
@@ -436,21 +436,21 @@ discard block |
||
| 436 | 436 | ); |
| 437 | 437 | $status = 200; |
| 438 | 438 | } |
| 439 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 439 | + catch (\Aimeos\MShop\Exception $e) |
|
| 440 | 440 | { |
| 441 | 441 | $status = 404; |
| 442 | - $view->errors = array( array( |
|
| 443 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 442 | + $view->errors = array(array( |
|
| 443 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
| 444 | 444 | 'detail' => $e->getTraceAsString(), |
| 445 | - ) ); |
|
| 445 | + )); |
|
| 446 | 446 | } |
| 447 | - catch( \Exception $e ) |
|
| 447 | + catch (\Exception $e) |
|
| 448 | 448 | { |
| 449 | 449 | $status = 500; |
| 450 | - $view->errors = array( array( |
|
| 450 | + $view->errors = array(array( |
|
| 451 | 451 | 'title' => $e->getMessage(), |
| 452 | 452 | 'detail' => $e->getTraceAsString(), |
| 453 | - ) ); |
|
| 453 | + )); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** admin/jsonadm/standard/template-options |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $tplconf = 'admin/jsonadm/standard/template-options'; |
| 482 | 482 | $default = 'options-default.php'; |
| 483 | 483 | |
| 484 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 484 | + return $view->render($view->config($tplconf, $default)); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | |
@@ -493,23 +493,23 @@ discard block |
||
| 493 | 493 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
| 494 | 494 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
| 495 | 495 | */ |
| 496 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
| 496 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
| 497 | 497 | { |
| 498 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 498 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 499 | 499 | |
| 500 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 500 | + if (($id = $view->param('id')) == null) |
|
| 501 | 501 | { |
| 502 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
| 503 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 502 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
| 503 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - $ids = $this->getIds( $request ); |
|
| 507 | - $manager->deleteItems( $ids ); |
|
| 508 | - $view->total = count( $ids ); |
|
| 506 | + $ids = $this->getIds($request); |
|
| 507 | + $manager->deleteItems($ids); |
|
| 508 | + $view->total = count($ids); |
|
| 509 | 509 | } |
| 510 | 510 | else |
| 511 | 511 | { |
| 512 | - $manager->deleteItem( $id ); |
|
| 512 | + $manager->deleteItem($id); |
|
| 513 | 513 | $view->total = 1; |
| 514 | 514 | } |
| 515 | 515 | |
@@ -523,14 +523,14 @@ discard block |
||
| 523 | 523 | * @param \Aimeos\MW\View\Iface $view View instance |
| 524 | 524 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 525 | 525 | */ |
| 526 | - protected function getAggregate( \Aimeos\MW\View\Iface $view ) |
|
| 526 | + protected function getAggregate(\Aimeos\MW\View\Iface $view) |
|
| 527 | 527 | { |
| 528 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 528 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 529 | 529 | |
| 530 | - $key = $view->param( 'aggregate' ); |
|
| 530 | + $key = $view->param('aggregate'); |
|
| 531 | 531 | |
| 532 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 533 | - $view->data = $manager->aggregate( $search, $key ); |
|
| 532 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 533 | + $view->data = $manager->aggregate($search, $key); |
|
| 534 | 534 | |
| 535 | 535 | return $view; |
| 536 | 536 | } |
@@ -542,27 +542,27 @@ discard block |
||
| 542 | 542 | * @param \Aimeos\MW\View\Iface $view View instance |
| 543 | 543 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 544 | 544 | */ |
| 545 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
| 545 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
| 546 | 546 | { |
| 547 | 547 | $total = 1; |
| 548 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 549 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
| 548 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 549 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
| 550 | 550 | |
| 551 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 551 | + if (($id = $view->param('id')) == null) |
|
| 552 | 552 | { |
| 553 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 554 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
| 555 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
| 556 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
| 553 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 554 | + $view->data = $manager->searchItems($search, array(), $total); |
|
| 555 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
| 556 | + $view->listItems = $this->getListItems($view->data, $include); |
|
| 557 | 557 | } |
| 558 | 558 | else |
| 559 | 559 | { |
| 560 | - $view->data = $manager->getItem( $id, array() ); |
|
| 561 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
| 562 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
| 560 | + $view->data = $manager->getItem($id, array()); |
|
| 561 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
| 562 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
| 565 | + $view->refItems = $this->getRefItems($view->listItems); |
|
| 566 | 566 | $view->total = $total; |
| 567 | 567 | |
| 568 | 568 | return $view; |
@@ -576,9 +576,9 @@ discard block |
||
| 576 | 576 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 577 | 577 | * @deprecated 2016.06 Use getItems() instead |
| 578 | 578 | */ |
| 579 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
| 579 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
| 580 | 580 | { |
| 581 | - return $this->getItems( $view ); |
|
| 581 | + return $this->getItems($view); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -590,33 +590,33 @@ discard block |
||
| 590 | 590 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
| 591 | 591 | * @return \Aimeos\MW\View\Iface Updated view instance |
| 592 | 592 | */ |
| 593 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
| 593 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
| 594 | 594 | { |
| 595 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
| 596 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 595 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
| 596 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 599 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 600 | 600 | |
| 601 | - if( is_array( $request->data ) ) |
|
| 601 | + if (is_array($request->data)) |
|
| 602 | 602 | { |
| 603 | - $data = $this->saveData( $manager, $request ); |
|
| 603 | + $data = $this->saveData($manager, $request); |
|
| 604 | 604 | |
| 605 | 605 | $view->data = $data; |
| 606 | - $view->total = count( $data ); |
|
| 606 | + $view->total = count($data); |
|
| 607 | 607 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 608 | 608 | } |
| 609 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 609 | + elseif (($id = $view->param('id')) != null) |
|
| 610 | 610 | { |
| 611 | 611 | $request->data->id = $id; |
| 612 | - $data = $this->saveEntry( $manager, $request->data ); |
|
| 612 | + $data = $this->saveEntry($manager, $request->data); |
|
| 613 | 613 | |
| 614 | 614 | $view->data = $data; |
| 615 | 615 | $view->total = 1; |
| 616 | 616 | } |
| 617 | 617 | else |
| 618 | 618 | { |
| 619 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
| 619 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | return $view; |
@@ -631,31 +631,31 @@ discard block |
||
| 631 | 631 | * @param array &$header Associative list of HTTP headers as value/result parameter |
| 632 | 632 | * @return \Aimeos\MW\View\Iface Updated view instance |
| 633 | 633 | */ |
| 634 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
| 634 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
| 635 | 635 | { |
| 636 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
| 637 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 636 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
| 637 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
| 641 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
| 640 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
| 641 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | |
| 645 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 645 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 646 | 646 | |
| 647 | - if( is_array( $request->data ) ) |
|
| 647 | + if (is_array($request->data)) |
|
| 648 | 648 | { |
| 649 | - $data = $this->saveData( $manager, $request ); |
|
| 649 | + $data = $this->saveData($manager, $request); |
|
| 650 | 650 | |
| 651 | 651 | $view->data = $data; |
| 652 | - $view->total = count( $data ); |
|
| 652 | + $view->total = count($data); |
|
| 653 | 653 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 654 | 654 | } |
| 655 | 655 | else |
| 656 | 656 | { |
| 657 | 657 | $request->data->id = null; |
| 658 | - $data = $this->saveEntry( $manager, $request->data ); |
|
| 658 | + $data = $this->saveEntry($manager, $request->data); |
|
| 659 | 659 | |
| 660 | 660 | $view->data = $data; |
| 661 | 661 | $view->total = 1; |
@@ -38,24 +38,21 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $view = $this->deleteItems( $view, $body ); |
| 40 | 40 | $status = 200; |
| 41 | - } |
|
| 42 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 41 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 43 | 42 | { |
| 44 | 43 | $status = $e->getCode(); |
| 45 | 44 | $view->errors = array( array( |
| 46 | 45 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 47 | 46 | 'detail' => $e->getTraceAsString(), |
| 48 | 47 | ) ); |
| 49 | - } |
|
| 50 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 48 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 51 | 49 | { |
| 52 | 50 | $status = 404; |
| 53 | 51 | $view->errors = array( array( |
| 54 | 52 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 55 | 53 | 'detail' => $e->getTraceAsString(), |
| 56 | 54 | ) ); |
| 57 | - } |
|
| 58 | - catch( \Exception $e ) |
|
| 55 | + } catch( \Exception $e ) |
|
| 59 | 56 | { |
| 60 | 57 | $status = 500; |
| 61 | 58 | $view->errors = array( array( |
@@ -120,16 +117,14 @@ discard block |
||
| 120 | 117 | } |
| 121 | 118 | |
| 122 | 119 | $status = 200; |
| 123 | - } |
|
| 124 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 120 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 125 | 121 | { |
| 126 | 122 | $status = 404; |
| 127 | 123 | $view->errors = array( array( |
| 128 | 124 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 129 | 125 | 'detail' => $e->getTraceAsString(), |
| 130 | 126 | ) ); |
| 131 | - } |
|
| 132 | - catch( \Exception $e ) |
|
| 127 | + } catch( \Exception $e ) |
|
| 133 | 128 | { |
| 134 | 129 | $status = 500; |
| 135 | 130 | $view->errors = array( array( |
@@ -167,8 +162,7 @@ discard block |
||
| 167 | 162 | */ |
| 168 | 163 | $tplconf = 'admin/jsonadm/standard/template-aggregate'; |
| 169 | 164 | $default = 'aggregate-default.php'; |
| 170 | - } |
|
| 171 | - else |
|
| 165 | + } else |
|
| 172 | 166 | { |
| 173 | 167 | /** admin/jsonadm/standard/template-get |
| 174 | 168 | * Relative path to the JSON API template for GET requests |
@@ -220,24 +214,21 @@ discard block |
||
| 220 | 214 | { |
| 221 | 215 | $view = $this->patchItems( $view, $body, $header ); |
| 222 | 216 | $status = 200; |
| 223 | - } |
|
| 224 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 217 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 225 | 218 | { |
| 226 | 219 | $status = $e->getCode(); |
| 227 | 220 | $view->errors = array( array( |
| 228 | 221 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 229 | 222 | 'detail' => $e->getTraceAsString(), |
| 230 | 223 | ) ); |
| 231 | - } |
|
| 232 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 224 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 233 | 225 | { |
| 234 | 226 | $status = 404; |
| 235 | 227 | $view->errors = array( array( |
| 236 | 228 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 237 | 229 | 'detail' => $e->getTraceAsString(), |
| 238 | 230 | ) ); |
| 239 | - } |
|
| 240 | - catch( \Exception $e ) |
|
| 231 | + } catch( \Exception $e ) |
|
| 241 | 232 | { |
| 242 | 233 | $status = 500; |
| 243 | 234 | $view->errors = array( array( |
@@ -295,24 +286,21 @@ discard block |
||
| 295 | 286 | { |
| 296 | 287 | $view = $this->postItems( $view, $body, $header ); |
| 297 | 288 | $status = 201; |
| 298 | - } |
|
| 299 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 289 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 300 | 290 | { |
| 301 | 291 | $status = $e->getCode(); |
| 302 | 292 | $view->errors = array( array( |
| 303 | 293 | 'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 304 | 294 | 'detail' => $e->getTraceAsString(), |
| 305 | 295 | ) ); |
| 306 | - } |
|
| 307 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 296 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 308 | 297 | { |
| 309 | 298 | $status = 404; |
| 310 | 299 | $view->errors = array( array( |
| 311 | 300 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 312 | 301 | 'detail' => $e->getTraceAsString(), |
| 313 | 302 | ) ); |
| 314 | - } |
|
| 315 | - catch( \Exception $e ) |
|
| 303 | + } catch( \Exception $e ) |
|
| 316 | 304 | { |
| 317 | 305 | $status = 500; |
| 318 | 306 | $view->errors = array( array( |
@@ -435,16 +423,14 @@ discard block |
||
| 435 | 423 | 'Allow' => 'DELETE,GET,PATCH,POST,OPTIONS' |
| 436 | 424 | ); |
| 437 | 425 | $status = 200; |
| 438 | - } |
|
| 439 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 426 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 440 | 427 | { |
| 441 | 428 | $status = 404; |
| 442 | 429 | $view->errors = array( array( |
| 443 | 430 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 444 | 431 | 'detail' => $e->getTraceAsString(), |
| 445 | 432 | ) ); |
| 446 | - } |
|
| 447 | - catch( \Exception $e ) |
|
| 433 | + } catch( \Exception $e ) |
|
| 448 | 434 | { |
| 449 | 435 | $status = 500; |
| 450 | 436 | $view->errors = array( array( |
@@ -506,8 +492,7 @@ discard block |
||
| 506 | 492 | $ids = $this->getIds( $request ); |
| 507 | 493 | $manager->deleteItems( $ids ); |
| 508 | 494 | $view->total = count( $ids ); |
| 509 | - } |
|
| 510 | - else |
|
| 495 | + } else |
|
| 511 | 496 | { |
| 512 | 497 | $manager->deleteItem( $id ); |
| 513 | 498 | $view->total = 1; |
@@ -554,8 +539,7 @@ discard block |
||
| 554 | 539 | $view->data = $manager->searchItems( $search, array(), $total ); |
| 555 | 540 | $view->childItems = $this->getChildItems( $view->data, $include ); |
| 556 | 541 | $view->listItems = $this->getListItems( $view->data, $include ); |
| 557 | - } |
|
| 558 | - else |
|
| 542 | + } else |
|
| 559 | 543 | { |
| 560 | 544 | $view->data = $manager->getItem( $id, array() ); |
| 561 | 545 | $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
@@ -605,16 +589,14 @@ discard block |
||
| 605 | 589 | $view->data = $data; |
| 606 | 590 | $view->total = count( $data ); |
| 607 | 591 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 608 | - } |
|
| 609 | - elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 592 | + } elseif( ( $id = $view->param( 'id' ) ) != null ) |
|
| 610 | 593 | { |
| 611 | 594 | $request->data->id = $id; |
| 612 | 595 | $data = $this->saveEntry( $manager, $request->data ); |
| 613 | 596 | |
| 614 | 597 | $view->data = $data; |
| 615 | 598 | $view->total = 1; |
| 616 | - } |
|
| 617 | - else |
|
| 599 | + } else |
|
| 618 | 600 | { |
| 619 | 601 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
| 620 | 602 | } |
@@ -651,8 +633,7 @@ discard block |
||
| 651 | 633 | $view->data = $data; |
| 652 | 634 | $view->total = count( $data ); |
| 653 | 635 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 654 | - } |
|
| 655 | - else |
|
| 636 | + } else |
|
| 656 | 637 | { |
| 657 | 638 | $request->data->id = null; |
| 658 | 639 | $data = $this->saveEntry( $manager, $request->data ); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param array $templatePaths List of file system paths where the templates are stored |
| 34 | 34 | * @param string $path Name of the client separated by slashes, e.g "product/stock" |
| 35 | 35 | */ |
| 36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
| 36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
| 37 | 37 | { |
| 38 | 38 | $this->view = $view; |
| 39 | 39 | $this->context = $context; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param array $include List of resource types that should be fetched |
| 50 | 50 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 51 | 51 | */ |
| 52 | - protected function getChildItems( array $items, array $include ) |
|
| 52 | + protected function getChildItems(array $items, array $include) |
|
| 53 | 53 | { |
| 54 | 54 | return array(); |
| 55 | 55 | } |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
| 73 | 73 | * @return array List of domain names |
| 74 | 74 | */ |
| 75 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
| 75 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
| 76 | 76 | { |
| 77 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
| 77 | + if (($domains = $view->param('resource')) == '') |
|
| 78 | 78 | { |
| 79 | 79 | /** admin/jsonadm/domains |
| 80 | 80 | * A list of domain names whose clients are available for the JSON API |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
| 97 | 97 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
| 98 | 98 | ); |
| 99 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
| 99 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | return (array) $domains; |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | * @param \stdClass $request Decoded request body |
| 110 | 110 | * @return array List of item IDs |
| 111 | 111 | */ |
| 112 | - protected function getIds( $request ) |
|
| 112 | + protected function getIds($request) |
|
| 113 | 113 | { |
| 114 | 114 | $ids = array(); |
| 115 | 115 | |
| 116 | - if( isset( $request->data ) ) |
|
| 116 | + if (isset($request->data)) |
|
| 117 | 117 | { |
| 118 | - foreach( (array) $request->data as $entry ) |
|
| 118 | + foreach ((array) $request->data as $entry) |
|
| 119 | 119 | { |
| 120 | - if( isset( $entry->id ) ) { |
|
| 120 | + if (isset($entry->id)) { |
|
| 121 | 121 | $ids[] = $entry->id; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param array $include List of resource types that should be fetched |
| 135 | 135 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 136 | 136 | */ |
| 137 | - protected function getListItems( array $items, array $include ) |
|
| 137 | + protected function getListItems(array $items, array $include) |
|
| 138 | 138 | { |
| 139 | 139 | return array(); |
| 140 | 140 | } |
@@ -157,23 +157,23 @@ discard block |
||
| 157 | 157 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 158 | 158 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 159 | 159 | */ |
| 160 | - protected function getRefItems( array $listItems ) |
|
| 160 | + protected function getRefItems(array $listItems) |
|
| 161 | 161 | { |
| 162 | 162 | $list = $map = array(); |
| 163 | 163 | $context = $this->getContext(); |
| 164 | 164 | |
| 165 | - foreach( $listItems as $listItem ) { |
|
| 165 | + foreach ($listItems as $listItem) { |
|
| 166 | 166 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - foreach( $map as $domain => $ids ) |
|
| 169 | + foreach ($map as $domain => $ids) |
|
| 170 | 170 | { |
| 171 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
| 171 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
| 172 | 172 | |
| 173 | 173 | $search = $manager->createSearch(); |
| 174 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
| 174 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
| 175 | 175 | |
| 176 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
| 176 | + $list = array_merge($list, $manager->searchItems($search)); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | return $list; |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | * @param array $params List of criteria data with condition, sorting and paging |
| 210 | 210 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
| 211 | 211 | */ |
| 212 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 212 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 213 | 213 | { |
| 214 | - $this->initCriteriaConditions( $criteria, $params ); |
|
| 215 | - $this->initCriteriaSortations( $criteria, $params ); |
|
| 216 | - $this->initCriteriaSlice( $criteria, $params ); |
|
| 214 | + $this->initCriteriaConditions($criteria, $params); |
|
| 215 | + $this->initCriteriaSortations($criteria, $params); |
|
| 216 | + $this->initCriteriaSlice($criteria, $params); |
|
| 217 | 217 | |
| 218 | 218 | return $criteria; |
| 219 | 219 | } |
@@ -225,17 +225,17 @@ discard block |
||
| 225 | 225 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 226 | 226 | * @param array $params List of criteria data with condition, sorting and paging |
| 227 | 227 | */ |
| 228 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 228 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 229 | 229 | { |
| 230 | - if( !isset( $params['filter'] ) ) { |
|
| 230 | + if (!isset($params['filter'])) { |
|
| 231 | 231 | return; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $existing = $criteria->getConditions(); |
| 235 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
| 235 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
| 236 | 236 | |
| 237 | - $expr = array( $criteria->getConditions(), $existing ); |
|
| 238 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
| 237 | + $expr = array($criteria->getConditions(), $existing); |
|
| 238 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
@@ -245,12 +245,12 @@ discard block |
||
| 245 | 245 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 246 | 246 | * @param array $params List of criteria data with condition, sorting and paging |
| 247 | 247 | */ |
| 248 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 248 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 249 | 249 | { |
| 250 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
| 251 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
| 250 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
| 251 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
| 252 | 252 | |
| 253 | - $criteria->setSlice( $start, $size ); |
|
| 253 | + $criteria->setSlice($start, $size); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
@@ -260,24 +260,24 @@ discard block |
||
| 260 | 260 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 261 | 261 | * @param array $params List of criteria data with condition, sorting and paging |
| 262 | 262 | */ |
| 263 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 263 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 264 | 264 | { |
| 265 | - if( !isset( $params['sort'] ) ) { |
|
| 265 | + if (!isset($params['sort'])) { |
|
| 266 | 266 | return; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $sortation = array(); |
| 270 | 270 | |
| 271 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
| 271 | + foreach (explode(',', $params['sort']) as $sort) |
|
| 272 | 272 | { |
| 273 | - if( $sort[0] === '-' ) { |
|
| 274 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
| 273 | + if ($sort[0] === '-') { |
|
| 274 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
| 275 | 275 | } else { |
| 276 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
| 276 | + $sortation[] = $criteria->sort('+', $sort); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $criteria->setSortations( $sortation ); |
|
| 280 | + $criteria->setSortations($sortation); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | |
@@ -288,14 +288,14 @@ discard block |
||
| 288 | 288 | * @param \stdClass $request Object with request body data |
| 289 | 289 | * @return array List of items |
| 290 | 290 | */ |
| 291 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
| 291 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
| 292 | 292 | { |
| 293 | 293 | $data = array(); |
| 294 | 294 | |
| 295 | - if( isset( $request->data ) ) |
|
| 295 | + if (isset($request->data)) |
|
| 296 | 296 | { |
| 297 | - foreach( (array) $request->data as $entry ) { |
|
| 298 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
| 297 | + foreach ((array) $request->data as $entry) { |
|
| 298 | + $data[] = $this->saveEntry($manager, $entry); |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | |
@@ -310,22 +310,22 @@ discard block |
||
| 310 | 310 | * @param \stdClass $entry Object including "id" and "attributes" elements |
| 311 | 311 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
| 312 | 312 | */ |
| 313 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
| 313 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
| 314 | 314 | { |
| 315 | - if( isset( $entry->id ) ) { |
|
| 316 | - $item = $manager->getItem( $entry->id ); |
|
| 315 | + if (isset($entry->id)) { |
|
| 316 | + $item = $manager->getItem($entry->id); |
|
| 317 | 317 | } else { |
| 318 | 318 | $item = $manager->createItem(); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 322 | - $manager->saveItem( $item ); |
|
| 321 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 322 | + $manager->saveItem($item); |
|
| 323 | 323 | |
| 324 | - if( isset( $entry->relationships ) ) { |
|
| 325 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
| 324 | + if (isset($entry->relationships)) { |
|
| 325 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - return $manager->getItem( $item->getId() ); |
|
| 328 | + return $manager->getItem($item->getId()); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -336,28 +336,28 @@ discard block |
||
| 336 | 336 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
| 337 | 337 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
| 338 | 338 | */ |
| 339 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
| 340 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
| 339 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
| 340 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
| 341 | 341 | { |
| 342 | 342 | $id = $item->getId(); |
| 343 | - $listManager = $manager->getSubManager( 'lists' ); |
|
| 343 | + $listManager = $manager->getSubManager('lists'); |
|
| 344 | 344 | |
| 345 | - foreach( (array) $relationships as $domain => $list ) |
|
| 345 | + foreach ((array) $relationships as $domain => $list) |
|
| 346 | 346 | { |
| 347 | - if( isset( $list->data ) ) |
|
| 347 | + if (isset($list->data)) |
|
| 348 | 348 | { |
| 349 | - foreach( (array) $list->data as $data ) |
|
| 349 | + foreach ((array) $list->data as $data) |
|
| 350 | 350 | { |
| 351 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
| 351 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
| 352 | 352 | |
| 353 | - if( isset( $data->id ) ) { |
|
| 354 | - $listItem->setRefId( $data->id ); |
|
| 353 | + if (isset($data->id)) { |
|
| 354 | + $listItem->setRefId($data->id); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $listItem->setParentId( $id ); |
|
| 358 | - $listItem->setDomain( $domain ); |
|
| 357 | + $listItem->setParentId($id); |
|
| 358 | + $listItem->setDomain($domain); |
|
| 359 | 359 | |
| 360 | - $listManager->saveItem( $listItem, false ); |
|
| 360 | + $listManager->saveItem($listItem, false); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | } |
@@ -374,20 +374,20 @@ discard block |
||
| 374 | 374 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
| 375 | 375 | */ |
| 376 | 376 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
| 377 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
| 377 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
| 378 | 378 | { |
| 379 | - if( isset( $data->attributes ) ) |
|
| 379 | + if (isset($data->attributes)) |
|
| 380 | 380 | { |
| 381 | 381 | $attr = (array) $data->attributes; |
| 382 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
| 382 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
| 383 | 383 | |
| 384 | - if( isset( $attr[$key.'.type'] ) ) |
|
| 384 | + if (isset($attr[$key . '.type'])) |
|
| 385 | 385 | { |
| 386 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], array(), $domain ); |
|
| 387 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
| 386 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], array(), $domain); |
|
| 387 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - $item->fromArray( $attr ); |
|
| 390 | + $item->fromArray($attr); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | return $item; |
@@ -106,6 +106,7 @@ |
||
| 106 | 106 | * @param string $body Request body |
| 107 | 107 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
| 108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 109 | + * @param integer $status |
|
| 109 | 110 | * @return string Content for response body |
| 110 | 111 | */ |
| 111 | 112 | public function get( $body, array &$header, &$status ) |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 109 | 109 | * @return string Content for response body |
| 110 | 110 | */ |
| 111 | - public function get( $body, array &$header, &$status ) |
|
| 111 | + public function get($body, array &$header, &$status) |
|
| 112 | 112 | { |
| 113 | 113 | /** admin/jsonadm/partials/catalog/template-data |
| 114 | 114 | * Relative path to the data partial template file for the catalog client |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * @since 2016.07 |
| 126 | 126 | * @category Developer |
| 127 | 127 | */ |
| 128 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/catalog/template-data' ) ); |
|
| 128 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/catalog/template-data')); |
|
| 129 | 129 | |
| 130 | - return parent::get( $body, $header, $status ); |
|
| 130 | + return parent::get($body, $header, $status); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | * @param array $include List of resource types that should be fetched |
| 139 | 139 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 140 | 140 | */ |
| 141 | - protected function getChildItems( array $items, array $include ) |
|
| 141 | + protected function getChildItems(array $items, array $include) |
|
| 142 | 142 | { |
| 143 | 143 | $list = array(); |
| 144 | 144 | |
| 145 | - if( in_array( 'catalog', $include ) ) |
|
| 145 | + if (in_array('catalog', $include)) |
|
| 146 | 146 | { |
| 147 | - foreach( $items as $item ) { |
|
| 148 | - $list = array_merge( $list, $item->getChildren() ); |
|
| 147 | + foreach ($items as $item) { |
|
| 148 | + $list = array_merge($list, $item->getChildren()); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -159,27 +159,27 @@ discard block |
||
| 159 | 159 | * @param \Aimeos\MW\View\Iface $view View instance |
| 160 | 160 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 161 | 161 | */ |
| 162 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
| 162 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
| 163 | 163 | { |
| 164 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
| 165 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' ); |
|
| 166 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 164 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
| 165 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); |
|
| 166 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 167 | 167 | $total = 1; |
| 168 | 168 | |
| 169 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 169 | + if (($id = $view->param('id')) == null) |
|
| 170 | 170 | { |
| 171 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
| 172 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
| 173 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
| 171 | + $view->data = $manager->searchItems($search, array(), $total); |
|
| 172 | + $view->listItems = $this->getListItems($view->data, $include); |
|
| 173 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
| 174 | 174 | } |
| 175 | 175 | else |
| 176 | 176 | { |
| 177 | - $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
| 178 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
| 179 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
| 177 | + $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
| 178 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
| 179 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
| 182 | + $view->refItems = $this->getRefItems($view->listItems); |
|
| 183 | 183 | $view->total = $total; |
| 184 | 184 | |
| 185 | 185 | return $view; |
@@ -193,18 +193,18 @@ discard block |
||
| 193 | 193 | * @param array $include List of resource types that should be fetched |
| 194 | 194 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 195 | 195 | */ |
| 196 | - protected function getListItems( array $items, array $include ) |
|
| 196 | + protected function getListItems(array $items, array $include) |
|
| 197 | 197 | { |
| 198 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
| 198 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
| 199 | 199 | |
| 200 | 200 | $search = $manager->createSearch(); |
| 201 | 201 | $expr = array( |
| 202 | - $search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ), |
|
| 203 | - $search->compare( '==', 'catalog.lists.domain', $include ), |
|
| 202 | + $search->compare('==', 'catalog.lists.parentid', array_keys($items)), |
|
| 203 | + $search->compare('==', 'catalog.lists.domain', $include), |
|
| 204 | 204 | ); |
| 205 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 205 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 206 | 206 | |
| 207 | - return $manager->searchItems( $search ); |
|
| 207 | + return $manager->searchItems($search); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | |
@@ -215,32 +215,32 @@ discard block |
||
| 215 | 215 | * @param \stdClass $entry Object including "id" and "attributes" elements |
| 216 | 216 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
| 217 | 217 | */ |
| 218 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
| 218 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
| 219 | 219 | { |
| 220 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
| 221 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
| 220 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
| 221 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
| 222 | 222 | |
| 223 | - if( isset( $entry->id ) ) |
|
| 223 | + if (isset($entry->id)) |
|
| 224 | 224 | { |
| 225 | - $item = $manager->getItem( $entry->id ); |
|
| 226 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 227 | - $manager->saveItem( $item ); |
|
| 225 | + $item = $manager->getItem($entry->id); |
|
| 226 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 227 | + $manager->saveItem($item); |
|
| 228 | 228 | |
| 229 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
| 230 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
| 229 | + if (isset($entry->parentid) && $targetId !== null) { |
|
| 230 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | else |
| 234 | 234 | { |
| 235 | 235 | $item = $manager->createItem(); |
| 236 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 237 | - $manager->insertItem( $item, $targetId, $refId ); |
|
| 236 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 237 | + $manager->insertItem($item, $targetId, $refId); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if( isset( $entry->relationships ) ) { |
|
| 241 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
| 240 | + if (isset($entry->relationships)) { |
|
| 241 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - return $manager->getItem( $item->getId() ); |
|
| 244 | + return $manager->getItem($item->getId()); |
|
| 245 | 245 | } |
| 246 | 246 | } |
@@ -171,8 +171,7 @@ discard block |
||
| 171 | 171 | $view->data = $manager->searchItems( $search, array(), $total ); |
| 172 | 172 | $view->listItems = $this->getListItems( $view->data, $include ); |
| 173 | 173 | $view->childItems = $this->getChildItems( $view->data, $include ); |
| 174 | - } |
|
| 175 | - else |
|
| 174 | + } else |
|
| 176 | 175 | { |
| 177 | 176 | $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
| 178 | 177 | $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
@@ -229,8 +228,7 @@ discard block |
||
| 229 | 228 | if( isset( $entry->parentid ) && $targetId !== null ) { |
| 230 | 229 | $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
| 231 | 230 | } |
| 232 | - } |
|
| 233 | - else |
|
| 231 | + } else |
|
| 234 | 232 | { |
| 235 | 233 | $item = $manager->createItem(); |
| 236 | 234 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
@@ -1,25 +1,25 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $options = 0; |
| 4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
| 4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
| 5 | 5 | $options = JSON_PRETTY_PRINT; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
| 9 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Catalog\Item\Iface $item, array $fields, array $listItems ) |
|
| 9 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Catalog\Item\Iface $item, array $fields, array $listItems) |
|
| 10 | 10 | { |
| 11 | 11 | $id = $item->getId(); |
| 12 | 12 | $attributes = $item->toArray(); |
| 13 | 13 | $type = $item->getResourceType(); |
| 14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
| 14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
| 15 | 15 | |
| 16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
| 17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
| 18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
| 19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
| 16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
| 17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
| 18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
| 19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
| 20 | 20 | |
| 21 | - if( isset( $fields[$type] ) ) { |
|
| 22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
| 21 | + if (isset($fields[$type])) { |
|
| 22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | $result = array( |
@@ -27,30 +27,30 @@ discard block |
||
| 27 | 27 | 'type' => $type, |
| 28 | 28 | 'attributes' => $attributes, |
| 29 | 29 | 'links' => array( |
| 30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
| 30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
| 31 | 31 | ), |
| 32 | 32 | 'relationships' => array() |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - foreach( $item->getChildren() as $childItem ) |
|
| 35 | + foreach ($item->getChildren() as $childItem) |
|
| 36 | 36 | { |
| 37 | 37 | $type = $childItem->getResourceType(); |
| 38 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
| 38 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - foreach( $listItems as $listId => $listItem ) |
|
| 41 | + foreach ($listItems as $listId => $listItem) |
|
| 42 | 42 | { |
| 43 | - if( $listItem->getParentId() == $id ) |
|
| 43 | + if ($listItem->getParentId() == $id) |
|
| 44 | 44 | { |
| 45 | 45 | $type = $listItem->getDomain(); |
| 46 | - $params = array( 'resource' => $listItem->getResourceType(), 'id' => $listId ); |
|
| 46 | + $params = array('resource' => $listItem->getResourceType(), 'id' => $listId); |
|
| 47 | 47 | |
| 48 | - $result['relationships'][$type][] = array( 'data' => array( |
|
| 48 | + $result['relationships'][$type][] = array('data' => array( |
|
| 49 | 49 | 'id' => $listItem->getRefId(), 'type' => $type, |
| 50 | 50 | 'attributes' => $listItem->toArray(), 'links' => array( |
| 51 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
| 51 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
| 52 | 52 | ) |
| 53 | - ) ); |
|
| 53 | + )); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -58,27 +58,27 @@ discard block |
||
| 58 | 58 | }; |
| 59 | 59 | |
| 60 | 60 | |
| 61 | -$fields = $this->param( 'fields', array() ); |
|
| 61 | +$fields = $this->param('fields', array()); |
|
| 62 | 62 | |
| 63 | -foreach( (array) $fields as $resource => $list ) { |
|
| 64 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
| 63 | +foreach ((array) $fields as $resource => $list) { |
|
| 64 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
| 68 | -$data = $this->get( 'data', array() ); |
|
| 69 | -$listItems = $this->get( 'listItems', array() ); |
|
| 68 | +$data = $this->get('data', array()); |
|
| 69 | +$listItems = $this->get('listItems', array()); |
|
| 70 | 70 | |
| 71 | -if( is_array( $data ) ) |
|
| 71 | +if (is_array($data)) |
|
| 72 | 72 | { |
| 73 | 73 | $response = array(); |
| 74 | 74 | |
| 75 | - foreach( $data as $item ) { |
|
| 76 | - $response[] = $build( $this, $item, $fields, $listItems ); |
|
| 75 | + foreach ($data as $item) { |
|
| 76 | + $response[] = $build($this, $item, $fields, $listItems); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | -elseif( $data !== null ) |
|
| 79 | +elseif ($data !== null) |
|
| 80 | 80 | { |
| 81 | - $response = $build( $this, $data, $fields, $listItems ); |
|
| 81 | + $response = $build($this, $data, $fields, $listItems); |
|
| 82 | 82 | } |
| 83 | 83 | else |
| 84 | 84 | { |
@@ -86,4 +86,4 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
| 89 | -echo json_encode( $response, $options ); |
|
| 90 | 89 | \ No newline at end of file |
| 90 | +echo json_encode($response, $options); |
|
| 91 | 91 | \ No newline at end of file |
@@ -52,12 +52,10 @@ |
||
| 52 | 52 | foreach( $data as $item ) { |
| 53 | 53 | $response[] = $build( $item, $fields, $childItems ); |
| 54 | 54 | } |
| 55 | -} |
|
| 56 | -elseif( $data !== null ) |
|
| 55 | +} elseif( $data !== null ) |
|
| 57 | 56 | { |
| 58 | 57 | $response = $build( $data, $fields, $childItems ); |
| 59 | -} |
|
| 60 | -else |
|
| 58 | +} else |
|
| 61 | 59 | { |
| 62 | 60 | $response = null; |
| 63 | 61 | } |
@@ -106,6 +106,7 @@ |
||
| 106 | 106 | * @param string $body Request body |
| 107 | 107 | * @param array &$header Variable which contains the HTTP headers and the new ones afterwards |
| 108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 109 | + * @param integer $status |
|
| 109 | 110 | * @return string Content for response body |
| 110 | 111 | */ |
| 111 | 112 | public function get( $body, array &$header, &$status ) |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 109 | 109 | * @return string Content for response body |
| 110 | 110 | */ |
| 111 | - public function get( $body, array &$header, &$status ) |
|
| 111 | + public function get($body, array &$header, &$status) |
|
| 112 | 112 | { |
| 113 | 113 | /** admin/jsonadm/partials/locale/site/template-data |
| 114 | 114 | * Relative path to the data partial template file for the locale site client |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * @since 2016.07 |
| 126 | 126 | * @category Developer |
| 127 | 127 | */ |
| 128 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/locale/site/template-data' ) ); |
|
| 128 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/locale/site/template-data')); |
|
| 129 | 129 | |
| 130 | - return parent::get( $body, $header, $status ); |
|
| 130 | + return parent::get($body, $header, $status); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | * @param array $include List of resource types that should be fetched |
| 139 | 139 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 140 | 140 | */ |
| 141 | - protected function getChildItems( array $items, array $include ) |
|
| 141 | + protected function getChildItems(array $items, array $include) |
|
| 142 | 142 | { |
| 143 | 143 | $list = array(); |
| 144 | 144 | |
| 145 | - if( in_array( 'locale/site', $include ) ) |
|
| 145 | + if (in_array('locale/site', $include)) |
|
| 146 | 146 | { |
| 147 | - foreach( $items as $item ) { |
|
| 148 | - $list = array_merge( $list, $item->getChildren() ); |
|
| 147 | + foreach ($items as $item) { |
|
| 148 | + $list = array_merge($list, $item->getChildren()); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -159,22 +159,22 @@ discard block |
||
| 159 | 159 | * @param \Aimeos\MW\View\Iface $view View instance |
| 160 | 160 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 161 | 161 | */ |
| 162 | - protected function getItems( \Aimeos\MW\View\Iface $view ) |
|
| 162 | + protected function getItems(\Aimeos\MW\View\Iface $view) |
|
| 163 | 163 | { |
| 164 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
| 165 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' ); |
|
| 166 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 164 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
| 165 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale/site'); |
|
| 166 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 167 | 167 | $total = 1; |
| 168 | 168 | |
| 169 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 169 | + if (($id = $view->param('id')) == null) |
|
| 170 | 170 | { |
| 171 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
| 172 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
| 171 | + $view->data = $manager->searchItems($search, array(), $total); |
|
| 172 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
| 173 | 173 | } |
| 174 | 174 | else |
| 175 | 175 | { |
| 176 | - $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
| 177 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
| 176 | + $view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
| 177 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $view->listItems = array(); |
@@ -192,32 +192,32 @@ discard block |
||
| 192 | 192 | * @param \stdClass $entry Object including "id" and "attributes" elements |
| 193 | 193 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
| 194 | 194 | */ |
| 195 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
| 195 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
| 196 | 196 | { |
| 197 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
| 198 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
| 197 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
| 198 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
| 199 | 199 | |
| 200 | - if( isset( $entry->id ) ) |
|
| 200 | + if (isset($entry->id)) |
|
| 201 | 201 | { |
| 202 | - $item = $manager->getItem( $entry->id ); |
|
| 203 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 204 | - $manager->saveItem( $item ); |
|
| 202 | + $item = $manager->getItem($entry->id); |
|
| 203 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 204 | + $manager->saveItem($item); |
|
| 205 | 205 | |
| 206 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
| 207 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
| 206 | + if (isset($entry->parentid) && $targetId !== null) { |
|
| 207 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | else |
| 211 | 211 | { |
| 212 | 212 | $item = $manager->createItem(); |
| 213 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 214 | - $manager->insertItem( $item, $targetId, $refId ); |
|
| 213 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 214 | + $manager->insertItem($item, $targetId, $refId); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if( isset( $entry->relationships ) ) { |
|
| 218 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
| 217 | + if (isset($entry->relationships)) { |
|
| 218 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - return $manager->getItem( $item->getId() ); |
|
| 221 | + return $manager->getItem($item->getId()); |
|
| 222 | 222 | } |
| 223 | 223 | } |
@@ -171,8 +171,7 @@ discard block |
||
| 171 | 171 | $view->data = $manager->searchItems( $search, array(), $total ); |
| 172 | 172 | $view->listItems = $this->getListItems( $view->data, $include ); |
| 173 | 173 | $view->childItems = $this->getChildItems( $view->data, $include ); |
| 174 | - } |
|
| 175 | - else |
|
| 174 | + } else |
|
| 176 | 175 | { |
| 177 | 176 | $view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
| 178 | 177 | $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
@@ -229,8 +228,7 @@ discard block |
||
| 229 | 228 | if( isset( $entry->parentid ) && $targetId !== null ) { |
| 230 | 229 | $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
| 231 | 230 | } |
| 232 | - } |
|
| 233 | - else |
|
| 231 | + } else |
|
| 234 | 232 | { |
| 235 | 233 | $item = $manager->createItem(); |
| 236 | 234 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
@@ -1,25 +1,25 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $options = 0; |
| 4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
| 4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
| 5 | 5 | $options = JSON_PRETTY_PRINT; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
| 9 | -$build = function( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Locale\Item\Site\Iface $item, array $fields ) |
|
| 9 | +$build = function(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Locale\Item\Site\Iface $item, array $fields) |
|
| 10 | 10 | { |
| 11 | 11 | $id = $item->getId(); |
| 12 | 12 | $attributes = $item->toArray(); |
| 13 | 13 | $type = $item->getResourceType(); |
| 14 | - $params = array( 'resource' => $item->getResourceType(), 'id' => $id ); |
|
| 14 | + $params = array('resource' => $item->getResourceType(), 'id' => $id); |
|
| 15 | 15 | |
| 16 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
| 17 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
| 18 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
| 19 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
| 16 | + $target = $view->config('admin/jsonadm/url/target'); |
|
| 17 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
| 18 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
| 19 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
| 20 | 20 | |
| 21 | - if( isset( $fields[$type] ) ) { |
|
| 22 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
| 21 | + if (isset($fields[$type])) { |
|
| 22 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | $result = array( |
@@ -27,41 +27,41 @@ discard block |
||
| 27 | 27 | 'type' => $type, |
| 28 | 28 | 'attributes' => $attributes, |
| 29 | 29 | 'links' => array( |
| 30 | - 'self' => $view->url( $target, $cntl, $action, $params, array(), $config ) |
|
| 30 | + 'self' => $view->url($target, $cntl, $action, $params, array(), $config) |
|
| 31 | 31 | ), |
| 32 | 32 | 'relationships' => array() |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - foreach( $item->getChildren() as $childItem ) |
|
| 35 | + foreach ($item->getChildren() as $childItem) |
|
| 36 | 36 | { |
| 37 | 37 | $type = $childItem->getResourceType(); |
| 38 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
| 38 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return $result; |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | 44 | |
| 45 | -$fields = $this->param( 'fields', array() ); |
|
| 45 | +$fields = $this->param('fields', array()); |
|
| 46 | 46 | |
| 47 | -foreach( (array) $fields as $resource => $list ) { |
|
| 48 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
| 47 | +foreach ((array) $fields as $resource => $list) { |
|
| 48 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
| 52 | -$data = $this->get( 'data', array() ); |
|
| 52 | +$data = $this->get('data', array()); |
|
| 53 | 53 | |
| 54 | -if( is_array( $data ) ) |
|
| 54 | +if (is_array($data)) |
|
| 55 | 55 | { |
| 56 | 56 | $response = array(); |
| 57 | 57 | |
| 58 | - foreach( $data as $item ) { |
|
| 59 | - $response[] = $build( $this, $item, $fields ); |
|
| 58 | + foreach ($data as $item) { |
|
| 59 | + $response[] = $build($this, $item, $fields); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | -elseif( $data !== null ) |
|
| 62 | +elseif ($data !== null) |
|
| 63 | 63 | { |
| 64 | - $response = $build( $this, $data, $fields ); |
|
| 64 | + $response = $build($this, $data, $fields); |
|
| 65 | 65 | } |
| 66 | 66 | else |
| 67 | 67 | { |
@@ -69,4 +69,4 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
| 72 | -echo json_encode( $response, $options ); |
|
| 73 | 72 | \ No newline at end of file |
| 73 | +echo json_encode($response, $options); |
|
| 74 | 74 | \ No newline at end of file |
@@ -52,12 +52,10 @@ |
||
| 52 | 52 | foreach( $data as $item ) { |
| 53 | 53 | $response[] = $build( $item, $fields, $childItems ); |
| 54 | 54 | } |
| 55 | -} |
|
| 56 | -elseif( $data !== null ) |
|
| 55 | +} elseif( $data !== null ) |
|
| 57 | 56 | { |
| 58 | 57 | $response = $build( $data, $fields, $childItems ); |
| 59 | -} |
|
| 60 | -else |
|
| 58 | +} else |
|
| 61 | 59 | { |
| 62 | 60 | $response = null; |
| 63 | 61 | } |