本文整理匯總了PHP中Repositories\SiteRepository::loadBySlug方法的典型用法代碼示例。如果您正苦於以下問題:PHP SiteRepository::loadBySlug方法的具體用法?PHP SiteRepository::loadBySlug怎麽用?PHP SiteRepository::loadBySlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Repositories\SiteRepository
的用法示例。
在下文中一共展示了SiteRepository::loadBySlug方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
function create(Request $request, Application $app)
{
$siteRepository = new SiteRepository();
$form = $app['form.factory']->create(new CreateForm());
if ('POST' == $request->getMethod()) {
$form->bind($request);
$data = $form->getData();
$site = $siteRepository->loadBySlug($data['slug']);
if ($site) {
$form->addError(new FormError('That address is already taken'));
}
if ($form->isValid()) {
$site = new SiteModel();
$site->setSlug($data['slug']);
$site->setTitle($data['title']);
if ($data['read'] == 'public') {
$site->setIsListedInIndex(true);
$site->setIsWebRobotsAllowed(true);
} else {
$site->setIsListedInIndex(false);
$site->setIsWebRobotsAllowed(false);
}
if ($data['write'] == 'public') {
$isAllUsersEditors = true;
} else {
$isAllUsersEditors = false;
}
$site->setPromptEmailsDaysInAdvance($app['config']->newSitePromptEmailsDaysInAdvance);
$countryRepository = new CountryRepository();
$siteQuotaRepository = new SiteQuotaRepository();
$siteRepository->create($site, $app['currentUser'], array($countryRepository->loadByTwoCharCode("GB")), $siteQuotaRepository->loadByCode($app['config']->newSiteHasQuotaCode), $isAllUsersEditors);
if ($app['config']->hasSSL) {
return $app->redirect("https://" . $site->getSlug() . "." . $app['config']->webSiteDomainSSL);
} else {
return $app->redirect("http://" . $site->getSlug() . "." . $app['config']->webSiteDomain);
}
}
}
$sites = array();
$repo = new SiteRepository();
if (isset($_COOKIE['sitesSeen'])) {
foreach (explode(",", $_COOKIE['sitesSeen']) as $siteID) {
if (intval($siteID) > 0) {
$site = $repo->loadById($siteID);
if ($site && !$site->getIsClosedBySysAdmin() && $site->getSlug() != $app['config']->siteSlugDemoSite) {
$sites[$site->getId()] = $site;
}
}
}
}
$srb = new SiteRepositoryBuilder();
$srb->setIsOpenBySysAdminsOnly(true);
$srb->setUserInterestedIn($app['currentUser']);
foreach ($srb->fetchAll() as $site) {
$sites[$site->getId()] = $site;
}
return $app['twig']->render('index/index/create.html.twig', array('form' => $form->createView(), 'sites' => $sites));
}
示例2: index
function index(Request $request, Application $app)
{
$form = $app['form.factory']->create(new NewSiteForm());
if ('POST' == $request->getMethod()) {
$form->bind($request);
$data = $form->getData();
$siteRepository = new SiteRepository();
$site = $siteRepository->loadBySlug($data['slug']);
if ($site) {
$form->addError(new FormError('That address is already taken'));
}
if ($form->isValid()) {
$userRepo = new UserAccountRepository();
$user = $userRepo->loadByEmail($data['email']);
if ($user) {
$data = $form->getData();
$site = new SiteModel();
$site->setSlug($data['slug']);
$site->setTitle($data['title']);
if ($data['read'] == 'public') {
$site->setIsListedInIndex(true);
$site->setIsWebRobotsAllowed(true);
} else {
$site->setIsListedInIndex(false);
$site->setIsWebRobotsAllowed(false);
}
if ($data['write'] == 'public') {
$site->setIsAllUsersEditors(true);
$site->setIsRequestAccessAllowed(false);
} else {
$site->setIsAllUsersEditors(false);
$site->setIsRequestAccessAllowed(true);
}
$site->setIsFeatureCuratedList($app['config']->newSiteHasFeatureCuratedList);
$site->setIsFeatureImporter($app['config']->newSiteHasFeatureImporter);
$site->setIsFeatureMap($app['config']->newSiteHasFeatureMap);
$site->setIsFeatureVirtualEvents($app['config']->newSiteHasFeatureVirtualEvents);
$site->setIsFeaturePhysicalEvents($app['config']->newSiteHasFeaturePhysicalEvents);
$site->setIsFeatureGroup($app['config']->newSiteHasFeatureGroup);
$site->setPromptEmailsDaysInAdvance($app['config']->newSitePromptEmailsDaysInAdvance);
$site->setIsFeatureTag($app['config']->newSiteHasFeatureTag);
$countryRepository = new CountryRepository();
$siteQuotaRepository = new SiteQuotaRepository();
$siteRepository->create($site, $user, array($countryRepository->loadByTwoCharCode("GB")), $siteQuotaRepository->loadByCode($app['config']->newSiteHasQuotaCode));
return $app->redirect("/sysadmin/site/" . $site->getId());
} else {
$app['flashmessages']->addError('Existing user not found!');
}
}
}
return $app['twig']->render('sysadmin/sitenew/index.html.twig', array('form' => $form->createView()));
}
示例3: build
protected function build($siteSlug, Request $request, Application $app)
{
$this->parameters = array('user' => null);
$repository = new SiteRepository();
$this->parameters['site'] = $repository->loadBySlug($siteSlug);
if (!$this->parameters['site']) {
return false;
}
if ($this->parameters['site']->getIsClosedBySysAdmin()) {
return false;
}
return true;
}
示例4: UserAccountModel
function test1()
{
$user = new UserAccountModel();
$user->setEmail("test@jarofgreen.co.uk");
$user->setUsername("test");
$user->setPassword("password");
$userRepo = new UserAccountRepository();
$userRepo->create($user);
$site = new SiteModel();
$site->setTitle("Test");
$site->setSlug("test");
$siteRepo = new SiteRepository();
$siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
$this->checkSiteInTest1($siteRepo->loadBySlug("test"));
}
示例5: setFromJSON
public function setFromJSON($json)
{
if (isset($json->event)) {
if (isset($json->event->summary)) {
$this->summary = $json->event->summary;
}
if (isset($json->event->description)) {
$this->description = $json->event->description;
}
if (isset($json->event->url)) {
$this->url = $json->event->url;
}
$timezone = new \DateTimeZone($this->timezone);
if (isset($json->event->start->str)) {
$this->start_at = new \DateTime($json->event->start->str, $timezone);
}
if (isset($json->event->end->str)) {
$this->end_at = new \DateTime($json->event->end->str, $timezone);
}
if (isset($json->event->country) && isset($json->event->country->code) && $json->event->country->code) {
$countryRepo = new CountryRepository();
// Delibrately setting NULL on failure so user gets an error message.
$this->country = $countryRepo->loadByTwoCharCode($json->event->country->code);
// TODO check allowed in this site
}
if (isset($json->event->timezone)) {
// Delibrately setting NULL on failure so user gets an error message.
$this->timezone = $this->country && in_array($json->event->timezone, $this->country->getTimezonesAsList()) ? $json->event->timezone : null;
}
}
if (isset($json->site)) {
$siteRepo = new SiteRepository();
if (isset($json->site->id)) {
$this->site = $siteRepo->loadById($json->site->id);
}
if (isset($json->site->slug)) {
$this->site = $siteRepo->loadBySlug($json->site->slug);
}
}
if (isset($json->user)) {
$userRepo = new UserAccountRepository();
if (isset($json->user->email)) {
$this->user = $userRepo->loadByEmail($json->user->email);
} else {
if (isset($json->user->username)) {
$this->user = $userRepo->loadByUserName($json->user->username);
}
}
}
if (isset($json->group)) {
$groupRepo = new GroupRepository();
if (isset($json->group->slug) && $this->site) {
$this->group = $groupRepo->loadBySlug($this->site, $json->group->slug);
} else {
if (isset($json->group->id)) {
$this->group = $groupRepo->loadById($json->group->id);
}
}
}
}
示例6: processThingsToDoAfterGetUser
protected function processThingsToDoAfterGetUser(Request $request, Application $app)
{
global $CONFIG;
$eventRepo = new EventRepository();
$areaRepo = new AreaRepository();
$event = null;
$area = null;
// Any events to add?
if ($request->query->has("event")) {
if ($CONFIG->isSingleSiteMode) {
$event = $eventRepo->loadBySiteIDAndEventSlug($CONFIG->singleSiteID, $request->query->get("event"));
} else {
$siteRepo = new SiteRepository();
$site = $siteRepo->loadBySlug($request->query->get("eventSite"));
if ($site) {
$event = $eventRepo->loadBySlug($site, $request->query->get("event"));
}
}
if ($event && $event->getIsAllowedForAfterGetUser()) {
if (!$app['websession']->hasArray("afterGetUserAddEvents")) {
$app['websession']->setArray("afterGetUserAddEvents", array($event->getId()));
} else {
if (!in_array($event->getId(), $app['websession']->getArray("afterGetUserAddEvents"))) {
$app['websession']->appendArray("afterGetUserAddEvents", $event->getId());
}
}
}
}
// Any areas to add?
if ($request->query->has("area")) {
if ($CONFIG->isSingleSiteMode) {
$area = $areaRepo->loadBySiteIDAndAreaSlug($CONFIG->singleSiteID, $request->query->get("area"));
} else {
$siteRepo = new SiteRepository();
$site = $siteRepo->loadBySlug($request->query->get("areaSite"));
if ($site) {
$area = $areaRepo->loadBySlug($site, $request->query->get("area"));
}
}
if ($area && $area->getIsAllowedForAfterGetUser()) {
if (!$app['websession']->hasArray("afterGetUserAddAreas")) {
$app['websession']->setArray("afterGetUserAddAreas", array($area->getId()));
} else {
if (!in_array($area->getId(), $app['websession']->getArray("afterGetUserAddAreas"))) {
$app['websession']->appendArray("afterGetUserAddAreas", $area->getId());
}
}
}
}
// Remove events?
if ($request->query->has("removeEventId")) {
$app['websession']->removeValueFromArray("afterGetUserAddEvents", $request->query->has("removeEventId"));
}
// Remove areas?
if ($request->query->has("removeAreaId")) {
$app['websession']->removeValueFromArray("afterGetUserAddAreas", $request->query->has("removeAreaId"));
}
// load events to show user
$this->parameters['afterGetUserAddEvents'] = array();
if ($app['websession']->hasArray("afterGetUserAddEvents")) {
foreach ($app['websession']->getArray("afterGetUserAddEvents") as $eventID) {
if ($event != null && $eventID == $event->getId()) {
if ($event->getIsAllowedForAfterGetUser()) {
$this->parameters['afterGetUserAddEvents'][] = $event;
}
} else {
$eventTmp = $eventRepo->loadByID($eventID);
if ($eventTmp && $eventTmp->getIsAllowedForAfterGetUser()) {
$this->parameters['afterGetUserAddEvents'][] = $eventTmp;
}
}
}
}
// load areas to show user
$this->parameters['afterGetUserAddAreas'] = array();
if ($app['websession']->hasArray("afterGetUserAddAreas")) {
foreach ($app['websession']->getArray("afterGetUserAddAreas") as $areaID) {
if ($area != null && $areaID == $area->getId()) {
if ($area->getIsAllowedForAfterGetUser()) {
$this->parameters['afterGetUserAddAreas'][] = $area;
}
} else {
$areaTmp = $areaRepo->loadByID($areaID);
if ($areaTmp && $areaTmp->getIsAllowedForAfterGetUser()) {
$this->parameters['afterGetUserAddAreas'][] = $areaTmp;
}
}
}
}
}