public function parseScopeArguments(array $scope)
    {
        $scope = new MosaicArray($scope);
        $result = [];

        // If "type" key has been provided, we have to typecast the result
        $type = $scope->getItem('type');

        // Get default scope argument value
        $default = $scope->getItem('default');

        // Get request parameter value
        $value = $this->getInputManager()->get($scope['alias'], null);

        // If there are no parameters with the scope name:
        // 1) in a case when no default value is set, return null to ignore this scope
        // 2) if default value is set, return it
        if (is_null($value)) {
            return !is_null($default) ? [$default] : null;
        }

        // If "keys" configuration key has been provided, we are dealing with an array parameter (e.g. <input name="somename[somekey]">)
        $keys = $scope->getItem('keys');

        // If "keys" are empty, we have to perform some DRY actions
        if (is_null($keys)) {
            $keys = ['default'];
            $value = ['default' => $value];
        }

        foreach ((array) $keys as $key) {
            $arg = $this->setType($value[$key], $type);

            // Empty arguments are not allowed by default in order to allow default scope argument values
            // Set allowEmpty option to `true` if you want to change this behavior
            if ($arg !== '' or $scope->getItem('allowEmpty')) {
                $result[] = $arg;
            }
        }

        return $result;
    }
public function parseScopeArguments(array $scope)
    {
        $scope = new MosaicArray($scope);
        $result = [];

        // If "type" key has been provided, we have to typecast the result
        $type = $scope->getItem('type');

        // Get default scope argument value
        $default = $scope->getItem('default');

        // Get request parameter value
        $value = $this->getInputManager()->get($scope['alias'], null);

        // If there are no parameters with the scope name:
        // 1) in a case when no default value is set, return null to ignore this scope
        // 2) if default value is set, return it
        if (is_null($value)) {
            return !is_null($default) ? [$default] : null;
        }

        // If "keys" configuration key has been provided, we are dealing with an array parameter (e.g. <input name="somename[somekey]">)
        $keys = $scope->getItem('keys');

        // If "keys" are empty, we have to perform some DRY actions
        if (is_null($keys)) {
            $keys = ['default'];
            $value = ['default' => $value];
        }

        foreach ((array) $keys as $key) {
            $arg = $this->setType($value[$key], $type);

            // Empty arguments are not allowed by default in order to allow default scope argument values
            // Set allowEmpty option to `true` if you want to change this behavior
            if ($arg !== '' or $scope->getItem('allowEmpty')) {
                $result[] = $arg;
            }
        }

        return $result;
    }
public function parseScopeArguments ( array $ scope ) { $ scope = new MosaicArray ( $ scope ) ; $ result = [ ] ; // If "type" key has been provided, we have to typecast the result $ type = $ scope -> getItem ( 'type' ) ; // Get default scope argument value $ default = $ scope -> getItem ( 'default' ) ; // Get request parameter value $ value = $ this -> getInputManager ( ) -> get ( $ scope [ 'alias' ] , null ) ; // If there are no parameters with the scope name: // 1) in a case when no default value is set, return null to ignore this scope // 2) if default value is set, return it if ( is_null ( $ value ) ) { return ! is_null ( $ default ) ? [ $ default ] : null ; } // If "keys" configuration key has been provided, we are dealing with an array parameter (e.g. <input name="somename[somekey]">) $ keys = $ scope -> getItem ( 'keys' ) ; // If "keys" are empty, we have to perform some DRY actions if ( is_null ( $ keys ) ) { $ keys = [ 'default' ] ; $ value = [ 'default' => $ value ] ; } foreach ( ( array ) $ keys as $ key ) { $ arg = $ this -> setType ( $ value [ $ key ] , $ type ) ; // Empty arguments are not allowed by default in order to allow default scope argument values // Set allowEmpty option to `true` if you want to change this behavior if ( $ arg !== '' or $ scope -> getItem ( 'allowEmpty' ) ) { $ result [ ] = $ arg ; } } return $ result ; }
Parse scope arguments from request parameters

@param  array $scope
@return array
Parse scope arguments from request parameters