本文整理汇总了PHP中Silex\Application::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::__construct方法的具体用法?PHP Application::__construct怎么用?PHP Application::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* App constructor.
*/
public function __construct()
{
parent::__construct();
$this->match('/', function () {
return '/';
});
/**
* process messages
*/
$this->match('update', function () {
$telegram = new Client(BOT_TOKEN);
$handler = new Handler($telegram);
return $handler->handle();
});
/**
* update hook settings/api
*/
$this->match('hook', function () {
$telegram = new Api(BOT_TOKEN);
$telegram->removeWebhook();
if (USE_WEBHOOK) {
$telegram->setWebhook(WEBHOOK, '../server-setup/files/cert/nginx.crt');
return 'hook set';
}
return 'hook-removed';
});
}
示例2: __construct
/**
* @param array $basePath
* @param Environment $environment
*/
public function __construct($basePath, Environment $environment)
{
parent::__construct();
$this['path'] = $basePath;
$this['env'] = $environment;
$this->bindPathsInApplicationContainer();
$this->bindConfiguration();
// Routes...
$this->register(new RouteServiceProvider());
// Services...
$this->register(new SessionServiceProvider());
$this->register(new FormServiceProvider());
$this->register(new UrlGeneratorServiceProvider());
$this->register(new ControllerResolverServiceProvider());
$this->register(new ServiceControllerServiceProvider());
$this->register(new DatabaseServiceProvider());
$this->register(new ValidatorServiceProvider());
$this->register(new TranslationServiceProvider());
$this->register(new SwiftmailerServiceProvider(), ['swiftmailer.options' => ['host' => $this->config('mail.host'), 'port' => $this->config('mail.port'), 'username' => $this->config('mail.username'), 'password' => $this->config('mail.password'), 'encryption' => $this->config('mail.encryption'), 'auth_mode' => $this->config('mail.auth_mode')]]);
$this->register(new SentryServiceProvider());
$this->register(new TwigServiceProvider());
$this->register(new HtmlPurifierServiceProvider());
$this->register(new SpotServiceProvider());
$this->register(new ImageProcessorProvider());
// Application Services...
$this->register(new ApplicationServiceProvider());
}
示例3: __construct
/**
* @param array $values
*/
public function __construct(array $values = array())
{
$values['bolt_version'] = '2.2.10';
$values['bolt_name'] = '';
$values['bolt_released'] = true;
// `true` for stable releases, `false` for alpha, beta and RC.
/** @internal Parameter to track a deprecated PHP version */
$values['deprecated.php'] = version_compare(PHP_VERSION, '5.4.0', '<');
parent::__construct($values);
$this->register(new PathServiceProvider());
// Initialize the config. Note that we do this here, on 'construct'.
// All other initialisation is triggered from bootstrap.php
// Warning!
// One of a valid ResourceManager ['resources'] or ClassLoader ['classloader']
// must be defined for working properly
if (!isset($this['resources'])) {
$this['resources'] = new Configuration\ResourceManager($this);
$this['resources']->compat();
} else {
$this['classloader'] = $this['resources']->getClassLoader();
}
$this['resources']->setApp($this);
$this->initConfig();
$this->initSession();
$this['resources']->initialize();
$this['debug'] = $this['config']->get('general/debug', false);
$this['debugbar'] = false;
// Initialize the 'editlink' and 'edittitle'.
$this['editlink'] = '';
$this['edittitle'] = '';
// Initialise the JavaScipt data gateway
$this['jsdata'] = array();
}
示例4: __construct
/**
* Instantiate a new Application.
*
* Objects and parameters can be passed as argument to the constructor.
*
* @param array $values The parameters or objects.
*/
public function __construct(array $values = array())
{
parent::__construct($values);
$this['debug'] = true;
$this->get('/', function () {
return 'Welcome at home';
});
$this->get('/welcome/{name}', function ($name) {
return sprintf('Welcome %s at home', $name);
});
$this->get('/dirs', 'Cpyree\\Controller\\DirectoryController::getDirectories');
$this->get('/dir-content', 'Cpyree\\Controller\\DirectoryController::getContentDir');
$this->get('/dir-genre', 'Cpyree\\Controller\\DirectoryController::getGenreDir');
$this->get('/set-matadata', 'Cpyree\\Controller\\DirectoryController::setMetadata');
$this->get('/move', 'Cpyree\\Controller\\DirectoryController::move');
$this->get('/delete', 'Cpyree\\Controller\\DirectoryController::delete');
//Security issue, disalow stream on all
$this->get('/stream', function (Request $request) {
if ($request->query->has('file')) {
$stream = new Streamer();
return $stream->start($request->query->get('file'));
}
die;
});
}
示例5: __construct
public function __construct(array $values = array())
{
$values['bolt_version'] = '2.0.0';
$values['bolt_name'] = 'almost beta';
parent::__construct($values);
// Initialize the config. Note that we do this here, on 'construct'.
// All other initialisation is triggered from bootstrap.php
// Warning!
// One of a valid ResourceManager ['resources'] or ClassLoader ['classloader']
// must be defined for working properly
if (!isset($this['resources'])) {
$this['resources'] = new Configuration\ResourceManager($this['classloader']);
$this['resources']->compat();
} else {
$this['classloader'] = $this['resources']->getClassLoader();
}
$this['resources']->setApp($this);
$this->initConfig();
$this['resources']->initialize();
$this['debug'] = $this['config']->get('general/debug', false);
$this['debugbar'] = false;
// Initialize the 'editlink' and 'edittitle'..
$this['editlink'] = '';
$this['edittitle'] = '';
}
示例6: __construct
public function __construct($values = array())
{
parent::__construct();
static::$app = $this;
foreach ($values as $key => $value) {
$this[$key] = $value;
}
Facade::setFacadeApplication($this);
// register the configserviceprovider so we can access the config
$this->register(new ConfigServiceProvider());
// grab the providers from the config and load them
$providers = $this['config']->get('app/providers');
foreach ($providers as $provider) {
$this->register(new $provider());
}
// set the locale (https://github.com/silexphp/Silex/issues/983)
$locale = $values['locale'];
if ($this['translator']) {
$this['translator']->setlocale($locale);
}
// register fieldtypes from config
$fieldTypesConfig = $this['config']->get('fieldtypes');
if ($fieldTypesConfig) {
$this['fieldtypes'] = $this['fieldtypes.factory']->fromConfig($fieldTypesConfig);
}
// register contenttypes from config
$contentTypeConfig = $this['config']->get('contenttypes');
if ($contentTypeConfig) {
$this['contenttypes'] = $this['contenttypes.factory']->fromConfig($contentTypeConfig);
}
}
示例7: __construct
public function __construct(array $values = [])
{
parent::__construct($values);
$this->registerProviders($this);
$this->registerServices($this);
$this->registerRoutes($this);
}
示例8: __construct
public function __construct(array $values = [])
{
parent::__construct($values);
$this['serializer'] = SerializerBuilder::create()->build();
BreweryBuilder::mountProviderIntoApplication($this->baseRouteApi, $this);
BeerBuilder::mountProviderIntoApplication($this->baseRouteApi, $this);
}
示例9: __construct
public function __construct($rootDir, $debug = true, array $values = [])
{
parent::__construct(['root_dir' => $rootDir, 'debug' => $debug] + $values);
$this->register(new ExceptionServiceProvider());
$this->register(new RoutingServiceProvider());
$this->register(new TackerServiceProvider());
}
示例10: __construct
public function __construct(array $values = array())
{
parent::__construct($values);
$this['config'] = $this->share(function ($this) {
return new ConfigService($this);
});
}
示例11: __construct
public function __construct(array $values = [])
{
parent::__construct($values);
$this->register(new Provider\ServiceControllerServiceProvider());
$this->setupServices();
$this->setupRouting();
}
示例12: __construct
public function __construct(array $config = array())
{
parent::__construct();
$this->values = array_merge($this->values, $config);
$this->register(new TwigServiceProvider(), array('twig.path' => __DIR__ . '/../../app/views'));
$this->register(new ServiceControllerServiceProvider());
}
示例13: __construct
/**
* @constructor
*
* @param EnvironmentInterface $environment
* @param Injector $injector
* @param array $configuration
*/
public function __construct(EnvironmentInterface $environment, Injector $injector, array $configuration)
{
$this->environment = $environment;
$this->injector = $injector;
$this->configuration = $configuration;
parent::__construct([]);
}
示例14: __construct
public function __construct(array $values = [])
{
$this->defaultScope = self::SCOPE_PUBLIC;
parent::__construct($values);
$this->defaultScope = self::SCOPE_PRIVATE;
$this->currentScope = self::SCOPE_PUBLIC;
}
示例15: __construct
/**
* @param array $basePath
* @param Environment $environment
*/
public function __construct($basePath, Environment $environment)
{
parent::__construct();
$this['path'] = $basePath;
$this['env'] = $environment;
$this->bindPathsInApplicationContainer();
$this->bindConfiguration();
// Register Gateways...
$this->register(new WebGatewayProvider());
$this->register(new ApiGatewayProvider());
$this->register(new OAuthGatewayProvider());
// Services...
$this->register(new SessionServiceProvider());
$this->register(new FormServiceProvider());
$this->register(new UrlGeneratorServiceProvider());
$this->register(new ControllerResolverServiceProvider());
$this->register(new DatabaseServiceProvider());
$this->register(new ValidatorServiceProvider());
$this->register(new TranslationServiceProvider());
$this->register(new MonologServiceProvider(), ['monolog.logfile' => $this->config('log.path') ?: "{$basePath}/log/app.log", 'monolog.name' => 'opencfp', 'monlog.level' => strtoupper($this->config('log.level') ?: 'debug')]);
$this->register(new SwiftmailerServiceProvider(), ['swiftmailer.options' => ['host' => $this->config('mail.host'), 'port' => $this->config('mail.port'), 'username' => $this->config('mail.username'), 'password' => $this->config('mail.password'), 'encryption' => $this->config('mail.encryption'), 'auth_mode' => $this->config('mail.auth_mode')]]);
$this->register(new SentryServiceProvider());
$this->register(new TwigServiceProvider());
$this->register(new HtmlPurifierServiceProvider());
$this->register(new SpotServiceProvider());
$this->register(new ImageProcessorProvider());
$this->register(new ResetEmailerServiceProvider());
// Application Services...
$this->register(new ApplicationServiceProvider());
$this->registerGlobalErrorHandler($this);
if ($timezone = $this->config('application.date_timezone')) {
date_default_timezone_set($timezone);
}
}