{@inheritdoc}
@throws \Exception
@throws BadMethodCallException
175960
public function load(array $configs, ContainerBuilder $container): void
    {
        $this->globalConfig = $this->processConfiguration($this->createConfiguration(), $configs);

        $container->setParameter(
            'sidus_admin.templating.fallback_template_directory',
            $this->globalConfig['fallback_template_directory']
        );

        foreach ((array) $this->globalConfig['configurations'] as $code => $adminConfiguration) {
            $this->createAdminServiceDefinition($code, $adminConfiguration, $container);
        }

        parent::load($configs, $container);
    }
810319
private function runAddedExceptions()
    {
        if (!empty($this->addedExceptions)) {
            foreach ($this->addedExceptions as $exception => $message) {
                throw new $exception($message);
                break;
            }
        }
    }
1159701
public function commit(array $attributes)
    {
        if ($this->can('commit')) {

            $this->flow->getLogger()->debug('Committing Resource: ' . json_encode($attributes));

            return BasicResponse::make(
                $this->performCommit($attributes)
            );
        }
        throw new \BadMethodCallException('Method '.__FUNCTION__.' does not exist');
    }
287301
public function loadInternal(array $configs, ContainerBuilder $container): void
    {
        $file = $this->getServiceName();
        if (!file_exists($file)) {
            throw new BadMethodCallException('"'.$file.'" doesn\'t exist!');
        }
        $parts = pathinfo($file);

        switch ($parts['extension']) {
            case 'xml':
                $loader = new XmlFileLoader($container, new FileLocator($parts['dirname']));
            break;
            case 'yml':
            case 'yaml':
                $loader = new YamlFileLoader($container, new FileLocator($parts['dirname']));
                break;
            default:
                throw new BadMethodCallException(
                    'This extension does not accept ".'
                    .$parts['extension']
                    .'" extension, only ".yml", ".yaml" or ".xml"!'
                );
        }
        $loader->load($parts['basename']);
        $this->setConfigParameters($configs, $container);
    }
431898
public function setDefinition($id, Definition $definition)
    {
        if ($this->isCompiled()) {
            throw new BadMethodCallException('Adding definition to a compiled container is not allowed');
        }

        $id = $this->normalizeId($id);

        unset($this->aliasDefinitions[$id], $this->removedIds[$id]);

        return $this->definitions[$id] = $definition;
    }
1021938
protected function doRequest($request)
    {
        if ($this->getRouter() === null) {
            throw new \BadMethodCallException("Router not set");
        }
        
        $this->reset(); // Reset before each HTTP request
        
        $psrRequest = $this->getRequestConvertor()->convert($request, $this->getBaseRequest());
        
        $router = $this->getRouter();
        $psrResponse = $router->handle($psrRequest, $this->getBaseResponse());
        
        return $this->getResponseConvertor()->convert($psrResponse);
    }
975680
protected function compileExpressions()
    {
        if (count($this->expressions) === 0) {
            throw new BadMethodCallException('Can\'t compile an empty expression');
        }
        if (count($this->expressions) === 1) {
            return reset($this->expressions);
        }

        $parts = [];

        foreach ($this->expressions as $expr) {
            $expr = '(?:' . $expr . ')';

            $parts[] = $expr;
        }

        return '(?:' . implode('|', $parts) . ')';
    }
609959
public function expected(AsserterInterface $asserter)
    {
        if (is_null($this->lastKey)) {
            throw new \BadMethodCallException();
        }

        $this->keys[$this->lastKey] = $asserter;

        return $this;
    }
365315
protected function set($key, $value)
    {
        if ($key === 'deleted') {
            throw new \InvalidArgumentException(
                '$key must not be "deleted". Please use setToDeleted() instead.',
                1331489276
            );
        }
        if ($this->isReadOnly()) {
            throw new \BadMethodCallException('set() must not be called on a read-only model.', 1331489292);
        }

        if ($this->isGhost()) {
            $this->load();
        }
        $this->data[$key] = $value;

        $this->markAsLoaded();
        $this->markAsDirty();
    }
215709
public function then($expression) : self
    {
        if (! is_array($this->switchBranch)) {
            throw new BadMethodCallException(static::class . '::then requires a valid case statement (call case() first).');
        }

        $this->switchBranch['then'] = $expression;

        if ($this->currentField) {
            $this->expr[$this->currentField]['$switch']['branches'][] = $this->ensureArray($this->switchBranch);
        } else {
            $this->expr['$switch']['branches'][] = $this->ensureArray($this->switchBranch);
        }

        $this->switchBranch = null;

        return $this;
    }
298434
public function validate() {
        if (!$this->_rules) {
            return true;
        }

        if (!$this->_file) {
            throw new IoException('No file present for validation');
        }

        foreach ($this->_rules as $rule) {
            $method = $rule['method'];

            if (!method_exists($this, $method)) {
                throw new BadMethodCallException(sprintf('Validation method %s does not exist', $method));
            }

            if (!call_user_func_array(array($this, $method), $rule['params'])) {
                throw new ValidationException($rule['message']);
            }
        }

        return true;
    }
1074321
public static function boot(array $config)
    {
        if (self::$booted) {
            return;
        }
        
        /**
         * Loader.
         */
        if (!isset($config['loader'])) {
            throw new BadMethodCallException(
                'Requires at least loader instance or configuration'
            );
        } else {
            if (is_array($config['loader'])) {
                // require_once __DIR__ . '/Rails/Loader/Loader.php';
                $loader = new Rails\Loader\Loader();
                
                if (isset($config['loader']['paths'])) {
                    $loader->addPaths($config['loader']['paths']);
                }
                
                if (isset($config['loader']['composerAutoloader'])) {
                    $loader->setComposerAutoloader(
                        $config['loader']['composerAutoloader']
                    );
                } else {
                    $loader->addPath(__DIR__ . '/Rails');
                }
                $loader->register();
            } elseif ($config['loader'] instanceof Rails\Loader\Loader) {
                $loader = $config['loader'];
            } else {
                throw new InvalidArgumentException(
                    sprintf(
                        'Loader must be either array or instance of Rails\Loader\Loader, %s passed',
                        gettype($config['loader'])
                    )
                );
            }
        }
        
        /**
         * Service Manager.
         */
        $sm = new Zend\ServiceManager\ServiceManager();
        self::$serviceManager = $sm;
        $sm->setService('loader', $loader);
        
        /**
         * Global configuration.
         */
        $sm->setService('rails.config', new Rails\ActiveSupport\ArrayObject([
            'use_cache' => false
        ]));
        
        /**
         * Inflector.
         */
        $sm->setFactory('inflector', function() {
            return new Rails\ActiveSupport\Inflector\Inflector(
                new Rails\ActiveSupport\Inflector\Inflections\EnglishInflections,
                'en'
            );
        });
        
        /**
         * Translator.
         */
        $sm->setFactory('i18n', function() {
            $tr = new Rails\I18n\LoadingTranslator();
            $tr->setDefaultLocale('en');
            $tr->setLoader(new Rails\I18n\Loader());
            
            
            # Add Rails' locales paths to i18n loader
            $tr->loader()->addPaths([
                __DIR__ . '/Rails/ActiveSupport/Carbon/locales',
                __DIR__ . '/Rails/I18n/locales',
            ]);
            
            return $tr;
        });
        
        self::$booted = true;
    }
1212420
public static function handleError(BadResponseException $exception)
    {
        $response_body = (string) $exception->getResponse()->getBody();
        $array_body = decode($response_body);

        $code = $exception->getResponse()->getStatusCode();

        $lookForKeys = ['message', 'code', 'error'];

        foreach ($lookForKeys as $key) {
            if (isset($array_body[$key])) {
                $message = $array_body[$key];
            }
        }

        if (!$message) {
            $message = 'unknown_error';
        }

        throw new JSONError($message, $code, $array_body);
    }
883468
public function badRequest(BadRequestException $exception, ServerRequestInterface $request) : ResponseInterface
    {
        $this->exception = $exception;

        $acceptType = $request->getHeader('Accept');
        if (is_array($acceptType) && count($acceptType) > 0 && strpos($acceptType[0], 'json') !== false) {
            return new JsonResponse(['error' => ['message' => 'Bad request sent', 'type' => 'bad_request']], 400);
        }

        if ($this->contentFor400) {
            $this->contentBlock = $this->contentFor400;
        } else {
            $this->contentBlock->addFile(__DIR__ . '/../../../../views/400.php', $this);
        }

        return HtmlResponse::create($this->template, 400);
    }
692854
private function executeEvent(AbstractEvent $event)
    {
        $eventName = ClassUtils::getShortName($event);
        $method    = sprintf('apply%s', (string) $eventName);

        if (!method_exists($this, $method)) {
            throw new BadMethodCallException(
                sprintf(
                    'You must define the %s::%s(%s $event) method in order to apply event named "%s".',
                    get_class($this),
                    $method,
                    get_class($event),
                    $eventName
                )
            );
        }

        $this->$method($event);
    }
333884
public function bindEntity($entity, $fields = null, $validatable = true)
    {
        if ($this->submitted) {
            throw new BadMethodCallException("Entities cannot be assigned after FormHandler::handleRequest has been called");
        }

        $this->entities[] = array('entity' => $entity, 'fields' => $fields, 'validatable' => $validatable);

        if ($entity instanceof EntityInterface) {
            $entityData = $entity->getFormData(array_keys($this->fields), $fields);
        } else {
            $entityData = $this->entityProcessor->getFromEntity($entity, array_keys($this->fields), $fields);
        }

        $entityData = $this->transformToFormData($entityData);

        $this->data = array_replace_recursive($this->data, $entityData);
    }
710209
private function get($field)
    {
        $this->initializeDoctrine();

        $property = $this->cm->getProperty($field);

        if (! $property) {
            throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getClassName() . "'");
        }

        return $this->{$field};
    }