Create an organization.

@param string $name        Organization name
@param string $billingMail Billing mail
@param string $displayName Optional display name

@throws GuzzleException
@throws \RuntimeException

@return Organization
972581
public function createOrganization($name, $billingMail, $displayName = '')
    {
        $options = ['json' => [
            'billing_email' => $billingMail,
        ]];

        if (!empty($displayName)) {
            $options['json']['display_name'] = $displayName;
        }

        $contents = $this
            ->call('PUT', self::ORGANIZATION_RESOURCE.'/'.$name, $options)
            ->getBody()
            ->getContents()
        ;

        return Organization::createFromJsonResponse($contents);
    }
1362552
public static function createAdmin(string $name, string $email, string $password)
    {
        if (static::where('email', $email)->exists()) {
            throw new Exception('User exist');
        }

        $permissions = collect();

        Dashboard::getPermission()
            ->collapse()
            ->each(function ($item) use ($permissions) {
                $permissions->put($item['slug'], true);
            });

        $user = static::create([
            'name'        => $name,
            'email'       => $email,
            'password'    => Hash::make($password),
            'permissions' => $permissions,
        ]);

        $user->notify(new DashboardNotification([
            'title'   => "Welcome {$name}",
            'message' => 'You can find the latest news of the project on the website',
            'action'  => 'https://orchid.software/',
            'type'    => DashboardNotification::INFO,
        ]));
    }
924918
public function to($mail, $name = null)
    {
        $this->message->addTo($mail, $name);
        return $this;
    }
985031
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $serviceName, $requestedName)
    {
        if (!isset($this->allowedServiceNames[$requestedName])) {
            throw new Exception\InvalidServiceNameException('Service "' . $requestedName . '" is not whitelisted');
        }


        if ($serviceLocator instanceof AbstractPluginManager) {
            /* @var $serviceLocator AbstractPluginManager */
            $this->serviceLocator = $serviceLocator->getServiceLocator();
        } else {
            $this->serviceLocator = $serviceLocator;
        }

        return parent::get($requestedName);
    }
469457
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        return substr($requestedName, - strlen(self::$termination)) === self::$termination && array_key_exists($this->removeTermination($requestedName), $this->getFormaterIndex($serviceLocator));
    }
1122970
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (substr($name, -5) != 'table') {
            return false;
        }

        if (empty($this->config)) {
            $config = $serviceLocator->get('config');
            $this->config = isset($config['tables']) ? $config['tables'] : [];
        }

        if (!isset($this->config[$requestedName])) {
            return false;
        }

        return true;
    }
781624
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        /** @var $config ProcessingConfig */
        $config = $serviceLocator->get("processing_config");

        $connector = $config->getConnectors()[$requestedName];


        if (! isset($connector['dbal_connection'])) throw new \InvalidArgumentException(sprintf('Missing dbal_connection for sql connector %s', $requestedName));
        if (! isset($connector['table'])) throw new \InvalidArgumentException(sprintf('Missing table definition for sql connector %s', $requestedName));

        $appConfig = $serviceLocator->get('config');


        if (! isset($appConfig['prooph.link.sqlconnector']['connections'][$connector['dbal_connection']])) throw new \InvalidArgumentException(sprintf('The DBAL connection %s can not be found. Please check config/autoload/sqlconnector.local.php!', $connector['dbal_connection']));

        $actionEventDispatcher = null;
        $listeners = null;

        if (isset($appConfig['prooph.link.sqlconnector']['action_listeners'][$requestedName])) {
            $actionEventDispatcher = new Zf2ActionEventDispatcher([$requestedName]);

            if (! is_array($appConfig['prooph.link.sqlconnector']['action_listeners'][$requestedName])) {
                throw new \InvalidArgumentException(
                    sprintf(
                        "Key prooph.link.sqlconnector.action_listeners.$requestedName of config should be of type array. Got %s",
                        gettype($appConfig['prooph.link.sqlconnector']['action_listeners'][$requestedName])
                    )
                );
            }

            foreach ($appConfig['prooph.link.sqlconnector']['action_listeners'][$requestedName] as $listenerAlias) {
                $listenerAggregate = $serviceLocator->get($listenerAlias);

                if (! $listenerAggregate instanceof ActionEventListenerAggregate) {
                    throw new \InvalidArgumentException(
                        sprintf(
                            "Action listeners for sqlconnector %s should be of type Prooph\\Common\\ActionEventListenerAggregate. Got %s",
                            $requestedName,
                            (is_object($listenerAggregate))? get_class($listenerAggregate) : gettype($listenerAggregate)
                        )
                    );
                }

                $listeners[] = $listenerAggregate;
            }
        }

        return new DoctrineTableGateway(
            DriverManager::getConnection($appConfig['prooph.link.sqlconnector']['connections'][$connector['dbal_connection']]),
            $connector['table'],
            $actionEventDispatcher,
            $listeners
        );
    }
1043855
public function findOrCreate(MailingList $list, $email)
    {
        /** @var SubscriptionRepository $repo */
        $repo = $this->em->getRepository('OpiferMailingListBundle:Subscription');

        $subscription = $repo->findInListByEmail($list, $email);

        if (! $subscription) {
            $subscription = new Subscription();
            $subscription->setMailingList($list);
            $subscription->setEmail($email);
        }

        return $subscription;
    }
668007
private function createCustomerWithUserAccount(
        $email,
        $password,
        $enabled = true,
        $firstName = null,
        $lastName = null,
        $role = null
    ) {
        /** @var ShopUserInterface $user */
        $user = $this->userFactory->createNew();

        /** @var CustomerInterface $customer */
        $customer = $this->customerFactory->createNew();

        $customer->setFirstName($firstName);
        $customer->setLastName($lastName);
        $customer->setEmail($email);

        $user->setUsername($email);
        $user->setPlainPassword($password);
        $user->setEnabled($enabled);
        if (null !== $role) {
            $user->addRole($role);
        }

        $customer->setUser($user);

        $this->sharedStorage->set('customer', $customer);

        return $customer;
    }
649546
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (null === $this->workflowServiceNamePrefix) {
            $this->workflowServiceNamePrefix = $this->buildWorkflowServiceNamePrefix($serviceLocator);
        }

        $flag = 0 === strpos($requestedName, $this->workflowServiceNamePrefix) && strlen($requestedName) > strlen($this->workflowServiceNamePrefix);
        return $flag;
    }
1330193
public function createMailbox(string $name): MailboxInterface
    {
        if (false === \imap_createmailbox($this->resource->getStream(), $this->server . \mb_convert_encoding($name, 'UTF7-IMAP', 'UTF-8'))) {
            throw new CreateMailboxException(\sprintf('Can not create "%s" mailbox at "%s"', $name, $this->server));
        }

        $this->mailboxNames = $this->mailboxes = null;
        $this->resource->clearLastMailboxUsedCache();

        return $this->getMailbox($name);
    }
976717
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->config[$requestedName];
        $dbAdapter = $serviceLocator->get(isset($config['adapter']) ? $config['adapter'] : 'db');

        /** @var \Zend\Db\TableGateway\TableGateway $table */
        if (isset($config['schema'])) {
            $config['table'] = new TableIdentifier($config['table'], $config['schema']);
        }

        $featureSet = new Feature\FeatureSet();
        $featureSet->addFeature(new Feature\CommonCallFeature($config['primary']));

        if (isset($config['invokable'])) {
            if (!class_exists($config['invokable'])) {
                throw new \RuntimeException("Class '{$config['invokable']}' not found ");
            }
            $table = new $config['invokable']($config['table'], $dbAdapter, $featureSet);
        } else {
            $table = new TableGateway($config['table'], $dbAdapter, $featureSet);
        }

        if (isset($config['row'])) {
            if ($config['row'] === true) {
                $config['row'] = 'Zend\Db\RowGateway\RowGateway';
            }

            if (is_string($config['row'])) {
                if (!class_exists($config['row'])) {
                    throw new \RuntimeException("Class '{$config['row']}' not found ");
                }

                $rowGatewayPrototype = new $config['row'](
                    $config['primary'],
                    $config['table'],
                    $dbAdapter, $table->getSql()
                );
            } else if (is_object($config['row'])) {
                $rowGatewayPrototype = $config['row'];
            } else {
                throw new \InvalidArgumentException('Error row argument');
            }

            $table->getResultSetPrototype()->setArrayObjectPrototype($rowGatewayPrototype);
        }

        return $table;
    }
17763
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->getConfig($serviceLocator);
        $config = $config[$requestedName];

        if (!isset($config['collectorFactory'])) {
            throw new MissingConfigurationException('Unable to create DataTable service: collectorFactory is missing');
        }

        if (!isset($config['columns']) || empty($config['columns'])) {
            throw new MissingConfigurationException('Unable to create DataTable service: columns are missing');
        }

        /** @var FactoryInterface $collectorFactory */
        $collectorFactory = new $config['collectorFactory'];

        $datatable = new DataTable(isset($config['id']) ? $config['id'] : $requestedName);
        $datatable->setCollector($collectorFactory->createService($serviceLocator));
        $columns = array();
        foreach ($config['columns'] as $columnConfig) {
            $columns[] = Column::factory($serviceLocator, $columnConfig);
        }
        $datatable->setColumns($columns);
        if (isset($config['classes'])) {
            $datatable->setClasses($config['classes']);
        }

        return $datatable;
    }
246831
public function setDisplayName($displayName)
    {
        if ($this->check()) {
            $userId = $this->data['user_id'];
            return $this->matrix()->request('PUT', $this->endpoint('profile/'.urlencode($userId).'/displayname'), [
                'displayname' => $displayName
            ], [
                'access_token' => $this->data['access_token']
            ]);
        }
        throw new \Exception('Not authenticated');
    }
248227
private function formatEmail($email, $name = null)
    {
        /**
         * Organization of the list of senders
         */
        if (!is_string($name) && preg_match('/^(.+)\s+<(.*)>\z$/', $email, $matches)) {
            array_shift($matches);
            $name = $matches[0];
            $email = $matches[1];
        }

        if (!Str::isMail($email)) {
            throw new \InvalidArgumentException("$email is not valid email.", E_USER_ERROR);
        }

        return [$name, $email];
    }
16417
public function setFrom(string $email, string $displayName = null) : void
    {
        $this->from = new Identity($email, $displayName);
    }
401190
public function createServiceWithName(ServiceLocatorInterface $services, $name, $requestedName)
    {
        $config = $this->getConfig($services);
        return AdapterServiceFactory::factory($config[$requestedName]);
    }