public function create($data)
    {
        /* ACCESS CHECK */
        if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }
        /* */

        $inputFilter = new SiteInputFilter();
        $inputFilter->setData($data);

        if (!$inputFilter->isValid()) {
            return new ApiJsonModel(
                [],
                1,
                'Some values are missing or invalid.',
                $inputFilter->getMessages()
            );
        }

        $data = $inputFilter->getValues();

        $siteManager = $this->getSiteManager();
        $userId = $this->getCurrentUserId();

        $data = $siteManager->prepareSiteData($data);
        /** @var \Rcm\Repository\Domain $domainRepo */
        $domainRepo = $this->getEntityManager()->getRepository(
            \Rcm\Entity\Domain::class
        );

        $data['domain'] = $domainRepo->createDomain(
            $data['domainName'],
            $userId,
            'Create new domain in ' . get_class($this)
        );

        /** @var \Rcm\Entity\Site $newSite */
        $newSite = new Site(
            $userId,
            'Create new site in ' . get_class($this)
        );

        $newSite->populate($data);
        // make sure we don't have a siteId
        $newSite->setSiteId(null);

        $newSite = $siteManager->createSite($newSite);

        return new ApiJsonModel($newSite, 0, 'Success');
    }
public function create($data)
    {
        /* ACCESS CHECK */
        if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }
        /* */

        $inputFilter = new SiteInputFilter();
        $inputFilter->setData($data);

        if (!$inputFilter->isValid()) {
            return new ApiJsonModel(
                [],
                1,
                'Some values are missing or invalid.',
                $inputFilter->getMessages()
            );
        }

        $data = $inputFilter->getValues();

        $siteManager = $this->getSiteManager();
        $userId = $this->getCurrentUserId();

        $data = $siteManager->prepareSiteData($data);
        /** @var \Rcm\Repository\Domain $domainRepo */
        $domainRepo = $this->getEntityManager()->getRepository(
            \Rcm\Entity\Domain::class
        );

        $data['domain'] = $domainRepo->createDomain(
            $data['domainName'],
            $userId,
            'Create new domain in ' . get_class($this)
        );

        /** @var \Rcm\Entity\Site $newSite */
        $newSite = new Site(
            $userId,
            'Create new site in ' . get_class($this)
        );

        $newSite->populate($data);
        // make sure we don't have a siteId
        $newSite->setSiteId(null);

        $newSite = $siteManager->createSite($newSite);

        return new ApiJsonModel($newSite, 0, 'Success');
    }
public function create ( $ data ) { /* ACCESS CHECK */ if ( ! $ this -> isAllowed ( ResourceName :: RESOURCE_SITES , 'admin' ) ) { $ this -> getResponse ( ) -> setStatusCode ( Response :: STATUS_CODE_401 ) ; return $ this -> getResponse ( ) ; } /* */ $ inputFilter = new SiteInputFilter ( ) ; $ inputFilter -> setData ( $ data ) ; if ( ! $ inputFilter -> isValid ( ) ) { return new ApiJsonModel ( [ ] , 1 , 'Some values are missing or invalid.' , $ inputFilter -> getMessages ( ) ) ; } $ data = $ inputFilter -> getValues ( ) ; $ siteManager = $ this -> getSiteManager ( ) ; $ userId = $ this -> getCurrentUserId ( ) ; $ data = $ siteManager -> prepareSiteData ( $ data ) ; /** @var \Rcm\Repository\Domain $domainRepo */ $ domainRepo = $ this -> getEntityManager ( ) -> getRepository ( \ Rcm \ Entity \ Domain :: class ) ; $ data [ 'domain' ] = $ domainRepo -> createDomain ( $ data [ 'domainName' ] , $ userId , 'Create new domain in ' . get_class ( $ this ) ) ; /** @var \Rcm\Entity\Site $newSite */ $ newSite = new Site ( $ userId , 'Create new site in ' . get_class ( $ this ) ) ; $ newSite -> populate ( $ data ) ; // make sure we don't have a siteId $ newSite -> setSiteId ( null ) ; $ newSite = $ siteManager -> createSite ( $ newSite ) ; return new ApiJsonModel ( $ newSite , 0 , 'Success' ) ; }
create - Create a site

@param array $data

@return mixed|JsonModel
create - Create a site