Convenience method to push the helper sets of a given entity manager into the application.
@param  Application|null          $application
@param  string                    $dmName
@throws \InvalidArgumentException
499804
public static function setApplicationDocumentManager(Application $application = null, $dmName)
    {
        if (is_null($application)) {
            throw new \InvalidArgumentException('Application instance needed!');
        }

        $helperSet = $application->getHelperSet();

        /** @var ManagerRegistry $doctrine */
        $doctrine = $helperSet->get('doctrine_mongodb');

        /** @var DocumentManager $dm */
        $dm = $doctrine->getManager($dmName);

        $helperSet->set(new DocumentManagerHelper($dm), 'dm');
    }
1279090
public void addApplication(App application)
    {
Utility.getLogger().info("addApp: " + application);
        m_vApplication.add(application);
        ((BaseApplication)application).setEnvironment(this);
        if ((m_applicationDefault == null)
                || ((!(m_applicationDefault instanceof MainApplication))) && (application instanceof MainApplication))
            this.setDefaultApplication(application);        // Initialization app
    }
940431
public function refreshApplication($app = null)
    {
        $this->app = $app instanceof Application ? $app : $this->createApplication();
    }
1269236
public function getRepository(EntityManagerInterface $entityManager, $entityName)
    {
        if (!in_array($entityName, $this->alreadyChecked) && isset($this->customEntyRepository[$entityName])) {
            $repositoryClass = $this->customEntyRepository[$entityName];
            if (!class_exists($repositoryClass)) {
                throw new \InvalidArgumentException(sprintf(
                    'Class %s does not exist. Cannot be used as %s custom repository.',
                    $repositoryClass,
                    $entityName
                ));
            }

            $metadata = $entityManager->getClassMetadata($entityName);
            $metadata->customRepositoryClassName = $repositoryClass;
        }

        $this->alreadyChecked[] = $entityName;

        return parent::getRepository($entityManager, $entityName);
    }
1130617
public void addToApplications(final Application application) {
		if (null == getApplications()) {
			setApplications(new java.util.TreeSet<Application>());
		}
		getApplications().add(application);
	}
81800
public static function generate($message = null, \CMain $APPLICATION = null)
    {
        if (null === $APPLICATION) {
            $APPLICATION = $GLOBALS['APPLICATION'];
        }

        if ($ex = $APPLICATION->GetException()) {
            throw new static($message ? $message . ': ' . $ex->GetString() : $ex->GetString());
        } else {
            throw new static($message ? $message : 'Unknown exception');
        }
    }
1006753
public function render($application = null)
    {
        $request = $this->setPathBackup();
        $form = $this->renderTemplate($this->subTemplate);
        $this->resetPathBackup($request);
        $this->setFormParameter($form);

        parent::render($application);
    }
1264180
protected function setApplicationName($applicationName)
    {
        if ($applicationName != strtolower($applicationName)) {
            throw new InvalidArgumentException('Application name should be lowercase');
        }
        if (preg_match('/[^a-z0-9]/', $applicationName)) {
            throw new InvalidArgumentException('Application name should contains only alphanumeric chars');
        }

        if (strlen($applicationName) > 16) {
            $message = 'Application name should be no longer than 16 characters';
            throw new InvalidArgumentException($message);
        }

        $this->applicationName = $applicationName;
    }
163196
public static function setApplicationConnection(Application $application = null, $connName)
    {
        if (is_null($application)) {
            throw new \InvalidArgumentException('Application instance needed!');
        }

        $helperSet = $application->getHelperSet();

        /** @var ManagerRegistry $doctrine */
        $doctrine = $helperSet->get('doctrine');

        /** @var Connection $connection */
        $connection = $doctrine->getConnection($connName);

        $helperSet->set(new ConnectionHelper($connection), 'db');
    }
810006
private function bindApplicationEvent(ServiceDefinition $application, string $event, string $class, string $property, string $argument = null): void
    {
        $argument = $argument ? ', $'.$argument : '';
        $application->addSetup(
            sprintf(
                '?->?[] = function ($application%s = null) use ($dispatcher) { $dispatcher->dispatch(?, new %s($application%s)); }',
                $argument,
                $class,
                $argument
            ),
            [
                '@self',
                $property,
                $event,
            ]
        );
    }
492849
public function setParentIdColumnName(string $parentIdColumnName): void
    {
        $parentIdColumnName = trim($parentIdColumnName);

        if (empty($parentIdColumnName)) {
            throw new InvalidArgumentException('parentIdColumnName cannot be empty');
        }

        $this->parentIdColumnName = $parentIdColumnName;
    }
1128509
public function init(ModuleManagerInterface $manager)
    {
        if (!$manager instanceof ModuleManager) {
            $errMsg =sprintf('Module manager not implement %s', ModuleManager::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }

        
        /** @var ServiceLocatorInterface $sm */
        $sm = $manager->getEvent()->getParam('ServiceManager');

        if (!$sm instanceof ServiceLocatorInterface) {
            $errMsg = sprintf('Service locator not implement %s', ServiceLocatorInterface::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }
        /** @var ServiceListenerInterface $serviceListener */
        $serviceListener = $sm->get('ServiceListener');
        if (!$serviceListener instanceof ServiceListenerInterface) {
            $errMsg = sprintf('ServiceListener not implement %s', ServiceListenerInterface::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }


        $serviceListener->addServiceManager(
            EntryNameResolverManagerInterface::class,
            EntryNameResolverManager::CONFIG_KEY,
            EntryNameResolverProviderInterface::class,
            'getEntryNameResolverConfig'
        );

    }
1126152
public function generate(DocumentManager $dm, $document)
    {
        if ($this->generator !== null) {
            $value = $this->generator->generate($dm, $document);

            $this->setValue($document, $value);
        }
    }
447438
public function postStartup(ApplicationInterface $application)
    {

        // load the object manager
        /** @var \AppserverIo\Psr\Di\ObjectManagerInterface $objectManager */
        $objectManager = $application->search(ObjectManagerInterface::IDENTIFIER);

        // register the beans found by annotations and the XML configuration
        /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */
        foreach ($objectManager->getObjectDescriptors() as $descriptor) {
            // if we found a singleton session bean with a startup callback instanciate it
            if ($descriptor instanceof SingletonSessionBeanDescriptorInterface && $descriptor->isInitOnStartup()) {
                $this->startupBeanTasks[] = new StartupBeanTask($application, $descriptor);
            }
        }
    }
982528
public static function createHelperSet(EntityManagerInterface $entityManager) : HelperSet
    {
        return new HelperSet(
            [
                'db' => new DBALConsole\Helper\ConnectionHelper($entityManager->getConnection()),
                'em' => new EntityManagerHelper($entityManager),
            ]
        );
    }
233554
private function addDefaultArgumentsAndOptions(Application $app) {
    $app->getDefinition()
      ->addOption(
        new InputOption('--define', '-D', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Define a configuration item value.', [])
      );
    $app->getDefinition()
      ->addOption(
        new InputOption('--environment', NULL, InputOption::VALUE_REQUIRED, 'Set the environment to load config from blt/[env].yml file.', [])
      );
    $app->getDefinition()
      ->addOption(
        new InputOption('--site', NULL, InputOption::VALUE_REQUIRED, 'The multisite to execute this command against.', [])
      );
  }
935100
public static void run(String aplicationName, String applicationDisplayName, String applicationVersion, Builder<Pcap, Void> builder) {
        Validate.notIllegalArgument(builder != null,
                new IllegalArgumentException("Pcap builder should be not null."));
        instance.context = new ApplicationContext(aplicationName, applicationDisplayName, applicationVersion, builder);
    }