findProspectOrCreateByProspectAndDomain : retrieve prospect with prospect and domain of create if not exits
@param string $prospect
@param Domain $domain

@return Prospect $prospectEntity
338770
public function findProspectOrCreateByProspectAndDomain($prospect, $domain)
    {
        $prospects = $this->getProspectMapper()->findBy(array('prospect' => $prospect, 'domain' => $domain));
        if (!empty($prospects)) {
            $prospectEntity = $prospects[0];
        } else {
            // Pas de prospect : alors on en crée un
            $prospectEntity = new ProspectEntity();
            $prospectEntity->setDomain($domain)
                ->setProspect($prospect);
            $prospectEntity = $this->getProspectMapper()->insert($prospectEntity);
        }
        return $prospectEntity;
    }
957530
public function findOneByDomainName(string $domainName): array
    {
        $queryBuilder = $this->createQuery();

        return (array)$queryBuilder->select('*')
            ->from($this->getTableName())
            ->where($queryBuilder->expr()->eq(
                'domainName',
                $queryBuilder->createNamedParameter($domainName, \PDO::PARAM_STR)
            ))
            ->execute()
            ->fetch();
    }
1011991
public function create(string $domain, string $address, array $params = [])
    {
        Assert::stringNotEmpty($domain);
        Assert::stringNotEmpty($address);

        $params['address'] = $address;

        $response = $this->httpPost(sprintf('/v3/%s/unsubscribes', $domain), $params);

        return $this->hydrateResponse($response, CreateResponse::class);
    }
1229962
public function createDomainAction(Domain $domain)
    {
        $this->domainRepository->add($domain);
        $this->addFlashMessage('The domain "%s" has been created.', 'Domain created', Message::SEVERITY_OK, [htmlspecialchars($domain)], 1412373192);
        $this->unsetLastVisitedNodeAndRedirect('edit', null, null, ['site' => $domain->getSite()]);
    }
153993
static Subject createSubject(final SubjectFactory subjectFactory, final String domain)
   {
      if (System.getSecurityManager() == null)
         return subjectFactory.createSubject(domain);

      return AccessController.doPrivileged(new PrivilegedAction<Subject>() 
      {
         public Subject run()
         {
            return subjectFactory.createSubject(domain);
         }
      });
   }
1145238
public function getRoles($name, ...$domain)
    {
        if (1 == \count($domain)) {
            $name = $domain[0].'::'.$name;
        } elseif (\count($domain) > 1) {
            throw new CasbinException('error: domain should be 1 parameter');
        }

        if (!$this->hasRole($name)) {
            return [];
        }

        $roles = $this->createRole($name)->getRoles();
        if (1 == \count($domain)) {
            foreach ($roles as $key => $value) {
                $roles[$key] = \array_slice($roles[$key], \strlen($domain[0]) + 2);
            }
        }

        return $roles;
    }
891760
static function retriveTokensByScope($scope, $domain = null) {
        $kind_schema = self::getGoogleAccessTokenKind();
        $str_query = "SELECT * FROM $kind_schema WHERE scopes='$scope'";
        if (!is_null($domain)) {
            $str_query = $str_query . " AND domain='$domain'";
        }
        return self::fetchAll($kind_schema, $str_query);
    }
165363
public static function getXDomainId($domain)
	{
		$db = \App::get('db');

		if (empty($domain) || ($domain == 'hubzero'))
		{
			return false;
		}

		$query = 'SELECT domain_id FROM `#__xdomains` WHERE domain=' . $db->quote($domain) . ';';
		$db->setQuery($query);

		$result = $db->loadObject();

		if (empty($result))
		{
			return false;
		}

		return $result->domain_id;
	}
203276
@SuppressWarnings("unused")
    public static Query createFor(Service service, Domain domain) {
        return new Query(service, domain, BROWSING_TIMEOUT);
    }
1060326
public function create($data)
    {
        $request = $this->getRequest();
        $response = $this->getResponse();
        $storyTellingService = $this->getStorytellingService();
        $domainService = $this->getDomainService();
        $user = null;
        
        $data = $this->fromJson();
        $storyMappingId = $data['story_mapping_id'];
        $storyMapping = $domainService->getStoryMappingMapper()->findById($storyMappingId);
        
        if (! $storyMapping) {
            $content = array(
                'result' => array(
                    'message' => 'Story missing',
                    'success' => false,
                    'data' => null,
                ),
            );
            
            $response->setContent($adapter->serialize($content));
            return $response;
        }

        $domain = $this->getDomainService()->getDomain($this);

        $storyTelling = new \PlaygroundFlow\Entity\OpenGraphStoryTelling();
        
        $storyTelling->setObject(json_encode($data['objects']))
            ->setPoints($storyMapping->getPoints())
            ->setSecretKey(null);

        if (!empty($data['user']['email'])) {
            // J'ai un user qui est identifié : user playground
            $user = $this->getUserService()->findUserOrCreateByEmail($data['user']['email']);
        
            // Association prospect - user si c'etait un prospect avant
            $prospect = $this->getProspectService()->getProspectMapper()->findOneBy(array('prospect' => $data['user']['anonymous']));
            if (!empty($prospect)) {
                if ($prospect->getUser() == null) {
                    $prospect->setUser($user);
                    $prospect = $this->getProspectService()->getProspectMapper()->update($prospect);
                }
                $storyTelling->setProspect($prospect);
            }
            $userDomain = $this->getUserDomainService()->findUserDomainOrCreateByUserAndDomain($user, $domain);
            // Association story telling à un utilisateur
            $storyTelling->setUser($user);
        } elseif (!empty($data['user']['anonymous'])) {
            // J'ai un anonymous
            $prospect = $this->getProspectService()->findProspectOrCreateByProspectAndDomain($data['user']['anonymous'], $domain);
            // Association story telling à un prospect
            $storyTelling->setProspect($prospect);
        }
        
        $storyTelling->setOpenGraphStoryMapping($storyMapping);
        // Creation de la storyTelling
        $storyTellingService->getStoryTellingMapper()->insert($storyTelling);

        // Si il y a un user, on met a jour son classement
        if (!empty($user)) {
            $this->getLeaderboardService()->addPoints($storyMapping, $user);
        }

        $storyTellingService->tellStory($storyTelling);
        
        $this->getEventManager()->trigger('story.'.$storyMapping->getId(), $this, array('storyTelling' => $storyTelling));
        
        $contentType = 'application/json';
        $adapter = '\Zend\Serializer\Adapter\Json';
        $response->getHeaders()->addHeaderLine('Content-Type', $contentType);
        $adapter = new $adapter;
        
        $data = $this->fromJson();
        $content = array(
            'result' => array(
                'message' => 'Post detected',
                'success' => true,
                'data' => $data['objects'],
            ),
        );
        
        $response->setContent($adapter->serialize($content));
        
        return $response;
    }
702411
public function createSubdomain($domainName, \Transip\Model\SubDomain $subDomain)
    {
        return $this->getSoapClient(array_merge(array($domainName, $subDomain), array('__method' => 'createSubdomain')))->createSubdomain($domainName, $subDomain);
    }
1042135
public function findUserDomainOrCreateByUserAndDomain($user, $domain)
    {
        $userDomain = $this->getUserDomainMapper()->findBy(array('user' => $user, 'domain' => $domain));
        if (empty($userDomain)) {
            $userDomain = new UserDomainEntity();
            $userDomain->setDomain($domain)
                ->setUser($user);
            $userDomain = $this->getUserDomainMapper()->insert($userDomain);
        }

        return $userDomain;
    }
560213
public function getTranslations($locale, $domain)
    {
        $conn = $this->getEntityManager()->getConnection();
        $stmt = $conn->executeQuery(
            'SELECT m.message, t.translation FROM message m JOIN message_translation t ON (t.message_id = m.id AND t.locale = ? ) WHERE m.domain = ?',
            [$locale, $domain]
        );
        while ($row = $stmt->fetch()) {
            yield $row['message'] => $row['translation'];
        }
    }
954625
protected function _getDomainManager( $domain )
	{
		$domain = strtolower( trim( $domain, "/ \n\t\r\0\x0B" ) );

		if( strlen( $domain ) === 0 ) {
			throw new Exception( 'An empty domain is invalid' );
		}

		if( !isset( $this->_domainManagers[$domain] ) )
		{
			$parts = explode( '/', $domain );

			foreach( $parts as $part )
			{
				if( ctype_alnum( $part ) === false ) {
					throw new Exception( sprintf( 'Invalid domain "%1$s"', $domain ) );
				}
			}

			if( ( $domainname = array_shift( $parts ) ) === null ) {
				throw new Exception( 'An empty domain is invalid' );
			}


			if( !isset( $this->_domainManagers[$domainname] ) )
			{
				$iface = 'MShop_Common_Manager_Interface';
				$factory = 'MShop_' . ucwords( $domainname ) . '_Manager_Factory';
				$manager = call_user_func_array( $factory . '::createManager', array( $this->_additional ) );

				if( !( $manager instanceof $iface ) ) {
					throw new Exception( sprintf( 'No factory "%1$s" found', $factory ) );
				}

				$this->_domainManagers[$domainname] = $manager;
			}


			foreach( $parts as $part )
			{
				$tmpname = $domainname .  '/' . $part;

				if( !isset( $this->_domainManagers[$tmpname] ) ) {
					$this->_domainManagers[$tmpname] = $this->_domainManagers[$domainname]->getSubManager( $part );
				}

				$domainname = $tmpname;
			}
		}

		return $this->_domainManagers[$domain];
	}
741520
public function create(DomainForm $form): Domain
    {
        $model = Domain::create($form->name, $form->alias, $form->url);
        $this->repository->save($model);
        return $model;
    }
1166369
public static function getRelationsConfig(string $domain, string $id) : array {
		$repositoryEntity = \App::$domain->get($domain)->repositories->get($id);
		$relations =  $repositoryEntity->relations();
		$relations = self::normalizeConfig($relations);
		$relationsCollection = Helper::forgeEntity($relations, RelationEntity::class, true, true);
		return $relationsCollection;
	}
1087447
public function newRecord($domain, array $parameters)
    {
        $this->checkParameters($parameters);

        return $this->processQuery(
            $this->buildRecordsQuery($domain, null, RecordsActions::ACTION_ADD, $parameters)
        );
    }