Beispiel #1
0
 public function testSpecifyType()
 {
     $ip = Domain::specifyType('127.0.0.1');
     $hostname = Domain::specifyType('example.com');
     $this->assertInstanceOf('ValueObjects\\Web\\IPAddress', $ip);
     $this->assertInstanceOf('ValueObjects\\Web\\Hostname', $hostname);
 }
 /**
  * @inheritdoc
  */
 public function register(Application $app)
 {
     $app['index.table_name'] = new StringLiteral('index_readmodel');
     $app['index.repository'] = $app->share(function (Application $app) {
         return new \CultuurNet\UDB3\ReadModel\Index\Doctrine\DBALRepository($app['dbal_connection'], $app['index.table_name'], $app['entity_iri_generator_factory']);
     });
     $app['index.projector'] = $app->share(function (Application $app) {
         $projector = new \CultuurNet\UDB3\ReadModel\Index\Projector($app['index.repository'], new CdbXmlCreatedByToUserIdResolver($app['uitid_users']), $app['local_domain'], \ValueObjects\Web\Domain::specifyType('uitdatabank.be'), $app['iri_offer_identifier_factory']);
         return $projector;
     });
     $app['index.schema_configurator'] = $app->share(function (Application $app) {
         return new SchemaConfigurator($app['index.table_name']);
     });
     // Add our schema configurator to the database installer.
     $app['database.installer'] = $app->extend('database.installer', function (DatabaseSchemaInstaller $installer, Application $app) {
         $installer->addSchemaConfigurator($app['index.schema_configurator']);
         return $installer;
     });
 }
Beispiel #3
0
 /**
  * Returns a new Url object from a native url string
  *
  * @param $url_string
  * @return Url
  */
 public static function fromNative()
 {
     $urlString = \func_get_arg(0);
     $user = \parse_url($urlString, PHP_URL_USER);
     $pass = \parse_url($urlString, PHP_URL_PASS);
     $host = \parse_url($urlString, PHP_URL_HOST);
     $queryString = \parse_url($urlString, PHP_URL_QUERY);
     $fragmentId = \parse_url($urlString, PHP_URL_FRAGMENT);
     $port = \parse_url($urlString, PHP_URL_PORT);
     $scheme = new SchemeName(\parse_url($urlString, PHP_URL_SCHEME));
     $user = $user ? new StringLiteral($user) : new StringLiteral('');
     $pass = $pass ? new StringLiteral($pass) : new StringLiteral('');
     $domain = Domain::specifyType($host);
     $path = new Path(\parse_url($urlString, PHP_URL_PATH));
     $portNumber = $port ? new PortNumber($port) : new NullPortNumber();
     $query = $queryString ? new QueryString(\sprintf('?%s', $queryString)) : new NullQueryString();
     $fragment = $fragmentId ? new FragmentIdentifier(\sprintf('#%s', $fragmentId)) : new NullFragmentIdentifier();
     return new self($scheme, $user, $pass, $domain, $portNumber, $path, $query, $fragment);
 }
 /**
  * Returns the domain part of the email address
  *
  * @return Domain
  */
 public function getDomainPart()
 {
     $parts = \explode('@', $this->toNative());
     $domain = \trim($parts[1], '[]');
     return Domain::specifyType($domain);
 }
Beispiel #5
0
$app = new Application();
$adapter = new \League\Flysystem\Adapter\Local(__DIR__);
$app['local_file_system'] = new \League\Flysystem\Filesystem($adapter);
$app['debug'] = true;
if (!isset($udb3ConfigLocation)) {
    $udb3ConfigLocation = __DIR__;
}
$app->register(new YamlConfigServiceProvider($udb3ConfigLocation . '/config.yml'));
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$app->register(new \CultuurNet\UDB3\Silex\SavedSearches\SavedSearchesServiceProvider());
$app->register(new \CultuurNet\UDB3\Silex\Variations\VariationsServiceProvider());
$app->register(new \CultuurNet\UDB3\Silex\Http\HttpServiceProvider());
$app->register(new Silex\Provider\ServiceControllerServiceProvider());
$app->register(new \CultuurNet\UDB3\Silex\Resque\ResqueCommandBusServiceProvider());
$app->register(new CorsServiceProvider(), array("cors.allowOrigin" => implode(" ", $app['config']['cors']['origins']), "cors.allowCredentials" => true));
$app['local_domain'] = \ValueObjects\Web\Domain::specifyType(parse_url($app['config']['url'])['host']);
/**
 * CultureFeed services.
 */
$app->register(new CultureFeedServiceProvider(), ['culturefeed.endpoint' => $app['config']['uitid']['base_url'], 'culturefeed.consumer.key' => $app['config']['uitid']['consumer']['key'], 'culturefeed.consumer.secret' => $app['config']['uitid']['consumer']['secret']]);
/**
 * Mailing service.
 */
$app->register(new Silex\Provider\SwiftmailerServiceProvider());
$app['swiftmailer.use_spool'] = false;
if ($app['config']['swiftmailer.options']) {
    $app['swiftmailer.options'] = $app['config']['swiftmailer.options'];
}
$app['timezone'] = $app->share(function (Application $app) {
    $timezoneName = empty($app['config']['timezone']) ? 'Europe/Brussels' : $app['config']['timezone'];
    return new DateTimeZone($timezoneName);