/**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
     $tables = util::array_get($config['tables']);
     if ($tables) {
         foreach ($tables as $tableDef) {
             $id = util::array_get($tableDef['id']);
             Ensure::isNotEmpty($id, "Missing [id] option in twentysteps_auto_tables table definition");
             $json = util::array_get($tableDef['dataTablesOptions']) ?: '{}';
             Ensure::isTrue($this->isValidJson($json), 'Encountered illegal JSON for twentysteps_auto_tables table with id [%s] in config: %s', $id, $json);
             $container->setParameter('twentysteps_auto_tables.config.' . $id, $tableDef);
         }
     }
     $defaultOpts = util::array_get($config['default_datatables_options']) ?: '{}';
     Ensure::isTrue($this->isValidJson($defaultOpts), 'Encountered illegal JSON in config: %s', $defaultOpts);
     $container->setParameter('twentysteps_auto_tables.default_datatables_options', $defaultOpts);
     $container->setParameter('twentysteps_auto_tables.config', $config);
 }
 private function parseMethodColumnDescriptors(\ReflectionClass $reflClass, &$columnDescriptors, AutoTablesConfiguration $config)
 {
     foreach ($reflClass->getMethods() as $method) {
         $column = null;
         $annot = $this->reader->getMethodAnnotation($method, '\\twentysteps\\Bundle\\AutoTablesBundle\\Annotations\\Column');
         if ($annot) {
             $column = new MethodColumnDescriptor($method);
             Ensure::isTrue(count($method->getParameters()) == 0, 'Failed to use [%s] as getter method, only parameterless methods supported for @Column', $method->getName());
             Ensure::isTrue(StaticStringy::startsWith($method->getName(), 'get'), 'Illegal method name [%s], getter methods must start with a get prefix', $method->getName());
             $column->addAutoTablesAnnotation($annot);
             $column->addAutoTablesConfig($config, $method->getName());
         }
         if ($column && $column->isUsable()) {
             $methodName = 'set' . substr($method->getName(), 3);
             if ($reflClass->hasMethod($methodName)) {
                 $setterMethod = $reflClass->getMethod($methodName);
                 Ensure::isEqual(1, count($setterMethod->getParameters()), 'setter method [%s] needs to have exactly one parameter', $setterMethod->getName());
                 $column->setSetterMethod($setterMethod);
             }
             $column->validate();
             $this->columnDescriptorMap[$column->getId()] = $column;
             $columnDescriptors[] = $column;
         }
     }
 }
 public function testEnsureTrueFailed()
 {
     $this->setExpectedException(self::ENSURE_EXCEPTION, 'check 1 2 3');
     Ensure::isTrue(1 == 2, 'check %s %s %s', 1, 2, 3);
 }
 /**
  * @return AutoTablesConfiguration
  */
 private function fetchAutoTablesConfiguration($args)
 {
     $tableId = $this->getRequiredParameter($args, 'tableId');
     $confKey = 'twentysteps_auto_tables.config.' . $tableId;
     Ensure::isTrue($this->container->hasParameter($confKey), 'Missing twentysteps_auto_tables table configuration with id [%s]', $tableId);
     $options = $this->container->getParameter($confKey);
     Ensure::isNotNull($options, 'Missing configuration for twentysteps_auto_tables table [%s]', $tableId);
     $globalConf = $this->fetchAutoTablesGlobalConfiguration();
     return $this->mergeColumnsConfiguration(new AutoTablesConfiguration($tableId, $options, $globalConf), $args);
 }