当前位置: 首页>>代码示例>>PHP>>正文


PHP Block::get方法代码示例

本文整理汇总了PHP中Block::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::get方法的具体用法?PHP Block::get怎么用?PHP Block::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Block的用法示例。


在下文中一共展示了Block::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run($request)
 {
     // update block/set titles
     // Name field has been reverted back to Title
     // DB::query("update Block set Name = Title");
     // DB::query("update BlockSet set Name = Title");
     // update block areas
     DB::query("\n\t\t\tupdate SiteTree_Blocks\n\t\t\tleft join Block on SiteTree_Blocks.BlockID = Block.ID\n\t\t\tset BlockArea = Block.Area\n\t\t\twhere BlockID = Block.ID\n\t\t");
     // update block sort
     DB::query("\n\t\t\tupdate SiteTree_Blocks\n\t\t\tleft join Block on SiteTree_Blocks.BlockID = Block.ID\n\t\t\tset Sort = Block.Weight\n\t\t\twhere BlockID = Block.ID\n\t\t");
     echo "BlockAreas, Sort updated<br />";
     // migrate global blocks
     $sc = SiteConfig::current_site_config();
     if ($sc->Blocks()->Count()) {
         $set = BlockSet::get()->filter('Title', 'Global')->first();
         if (!$set) {
             $set = BlockSet::create(array('Title' => 'Global'));
             $set->write();
         }
         foreach ($sc->Blocks() as $block) {
             if (!$set->Blocks()->find('ID', $block->ID)) {
                 $set->Blocks()->add($block, array('Sort' => $block->Weight, 'BlockArea' => $block->Area));
                 echo "Block #{$block->ID} added to Global block set<br />";
             }
         }
     }
     // publish blocks
     $blocks = Block::get()->filter('Published', 1);
     foreach ($blocks as $block) {
         $block->publish('Stage', 'Live');
         echo "Published Block #{$block->ID}<br />";
     }
 }
开发者ID:sekjal,项目名称:silverstripe-blocks,代码行数:33,代码来源:BlockUpgradeTask.php

示例2: addExisting

 /**
  * Add the GridFieldAddExistingSearchButton component to this grid config.
  *
  * @return $this
  **/
 public function addExisting()
 {
     $classes = $this->blockManager->getBlockClasses();
     $this->addComponent($add = new GridFieldAddExistingSearchButton());
     $add->setSearchList(Block::get()->filter(array('ClassName' => array_keys($classes))));
     return $this;
 }
开发者ID:sheadawson,项目名称:silverstripe-blocks,代码行数:12,代码来源:GridfieldConfig_BlockManager.php

示例3: run

 function run($request)
 {
     $data = (require_once __DIR__ . '/../../../BlockFiller.php');
     if ($data) {
         foreach (Block::get() as $block) {
             $block->delete();
         }
     }
     //Loop through all blocks, defined in root/BlockFiller.php
     foreach ($data as $key => $blockData) {
         $block = Block::create($blockData);
         //Find page by classname, so it can link block to page
         $page = Page::get()->filter(['ClassName' => $blockData['ClassName']])->first();
         //If page is found, write block
         if (isset($page->ID)) {
             $block->PageID = $page->ID;
             $block->write();
             //Loop through all blocks translations, which are defined in block section under 'trans'
             foreach ($blockData['trans'] as $key => $translation) {
                 $blockTrans = BlockTranslation::create($translation);
                 $blockTrans->BlockID = $block->ID;
                 $blockTrans->write();
             }
             var_dump($block->Title);
         }
     }
 }
开发者ID:kendu,项目名称:silverstripe-content-blocks,代码行数:27,代码来源:InsertBlocks.php

示例4: playerInteract

 public function playerInteract(PlayerInteractEvent $event)
 {
     if ($event->getBlock()->getId() == 35 && $event->getBlock()->getDamage() == 1) {
         $block->level->setBlock($block, Block::get(0));
         $player = $event->getPlayer();
         $player->getInventory()->addItem(new Item(ITEM::COOKIE, 0, 1));
         $player->sendPopup(TextFormat::GRAY . "RandomGive:\n" . TextFormat::YELLOW . "> " . TextFormat::GREEN . "You've received a cookie!");
     }
 }
开发者ID:Assistance-Team,项目名称:RandomGive,代码行数:9,代码来源:Main.php

示例5: getCMSFields

 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->push(TabSet::create('Root', $mainTab = new Tab('Main')));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $sort = 'ParentID';
     if ($this->has_extension('Sortable')) {
         $sort .= ', SortOrder';
     }
     $source = Block::get()->exclude('ClassName', 'VirtualBlock')->sort($sort)->map('ID', 'FullTitle');
     $fields->addFieldsToTab('Root.Main', array(ReadonlyField::create('Title', _t('Block.TITLE', 'Title'), $this->getTitle()), DropdownField::create('OriginalBlockID', _t('VirtualBlock.SELECT_ORIGINAL', 'Select original'), $source)));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:VisionaerAG,项目名称:page-blocks,代码行数:14,代码来源:VirtualBlock.php

示例6: MultiBlock

 public function MultiBlock($name)
 {
     $lang = i18n::get_locale();
     $blocksTrans = [];
     $blocks = Block::get()->filter(['Name' => $name])->sort('ID');
     foreach ($blocks as $key => $block) {
         $trans = $this->fetchBlockTrans($block, $lang);
         //Fallback to english if there is no translation for language
         if (count($trans) === 0) {
             $trans = $this->fetchBlockTrans($block, 'en_US');
         }
         array_push($blocksTrans, $trans);
     }
     return new ArrayList($blocksTrans);
 }
开发者ID:kendu,项目名称:silverstripe-content-blocks,代码行数:15,代码来源:ContentBlocksModule.php

示例7: dockedBlocks

 private function dockedBlocks()
 {
     $blocks = Block::get();
     $IDs = array();
     $ClassName = $this->owner->ClassName;
     $Classes = $blocks->map('ID', 'shownInClass');
     foreach ($Classes as $BlockID => $Class) {
         $listedClasses = explode(',', $Class);
         if (in_array($ClassName, $listedClasses)) {
             $IDs[] = $BlockID;
         }
     }
     $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder', 'ASC');
     return $blocks;
 }
开发者ID:salted-herring,项目名称:silverstripe-block,代码行数:15,代码来源:BlockinPage.php

示例8: getCMSFields

 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->push(TabSet::create('Root', $mainTab = new Tab('Main')));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $blockList = Block::get()->exclude('ClassName', 'VirtualBlock');
     // Apply the allowed blocks config to the virtual-block
     $allowed = $this->Parent()->config()->get('allowed_blocks');
     if (is_array($allowed)) {
         $blockList = $blockList->filter(array('ClassName' => $allowed));
     }
     $source = $blockList->sort('ParentID, SortOrder')->map('ID', 'FullTitle');
     $fields->addFieldsToTab('Root.Main', array(ReadonlyField::create('Title', _t('Block.TITLE', 'Title'), $this->getTitle()), DropdownField::create('OriginalBlockID', _t('VirtualBlock.SELECT_ORIGINAL', 'Select original'), $source)));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:bummzack-page-blocks,代码行数:16,代码来源:VirtualBlock.php

示例9: getDockedBlocks

 public function getDockedBlocks()
 {
     $blocks = Block::get()->filter(array('showBlockbyClass' => true));
     $blocks_map = $blocks->map('ID', 'shownInClass');
     foreach ($blocks_map as $blockID => $Classes) {
         $Classes = explode(',', $Classes);
         if (!in_array($this->owner->ClassName, $Classes)) {
             $blocks = $blocks->exclude('ID', $blockID);
         }
     }
     $published_blocks = new ArrayList();
     foreach ($blocks as $block) {
         if ($block->isPublished()) {
             $published_blocks->push($block);
         }
     }
     return $published_blocks->sort('SortOrder', 'ASC');
 }
开发者ID:salted-herring,项目名称:silverstripe-block,代码行数:18,代码来源:PrintBlocks.php

示例10: setAllowedBlocks

 /**
  * Set the allowed blocks for this gridfield
  * @param array $allowedBlocks a set of allowed class names, optionally mapped to titles
  */
 public function setAllowedBlocks(array $allowedBlocks)
 {
     $classes = null;
     if ($mc = $this->getComponentByType('GridFieldAddNewMultiClass')) {
         $search = $this->getComponentByType('GridFieldAddExistingSearchButton');
         $blockClasses = array_values(ClassInfo::subclassesFor('Block'));
         sort($blockClasses);
         if (is_array($allowedBlocks)) {
             $allowedClasses = array();
             foreach ($allowedBlocks as $class => $title) {
                 if (!is_string($class)) {
                     $class = $title;
                 }
                 if (in_array($class, $blockClasses)) {
                     $allowedClasses[] = $class;
                 }
             }
             $mc->setClasses($allowedClasses);
             if ($search) {
                 $search->setSearchList(Block::get()->filter(array('ParentID' => 0, 'ClassName' => $allowedClasses)));
             }
         } else {
             if ($search) {
                 $search->setSearchList(Block::get()->filter(array('ParentID' => 0)));
             }
             $mc->setClasses(null);
         }
     }
 }
开发者ID:VisionaerAG,项目名称:page-blocks,代码行数:33,代码来源:PageBlocks.php

示例11: startGame

 private function startGame($level)
 {
     $this->skywarsstarted == true;
     //put the array to true
     foreach ($this->getServer()->getLevelByName($level)->getPlayers() as $p) {
         //get every single player in the level
         if ($p->getGameMode() == 0) {
             $x = $p->getGroundX;
             $y = $p->getGroundY;
             //get the ground coordinates
             $z = $p->getGroundZ;
             //these are needed to break the glass under the player
             $this->getServer()->getLevelByName($level)->setBlock(new Vector3($x, $y, $z), Block::get(0, 0));
             $p->sendMessage("The game starts NOW!! Good luck!");
             $p->sendMessage("You can exit using: /sk exit");
         }
     }
     return true;
 }
开发者ID:EmreTr1,项目名称:SkyWarsForPE,代码行数:19,代码来源:Main.php

示例12: __construct

 public function __construct($meta = 0, $count = 1)
 {
     $this->block = Block::get(Item::REDSTONE_WIRE);
     parent::__construct(self::REDSTONE, 0, $count, "Redstone");
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:5,代码来源:Redstone.php

示例13: addExisting

 /**
  * Add the GridFieldAddExistingSearchButton component to this grid config.
  *
  * @return $this
  **/
 public function addExisting()
 {
     $this->addComponent($add = new GridFieldAddExistingSearchButton());
     $add->setSearchList(Block::get());
     return $this;
 }
开发者ID:anselmdk,项目名称:silverstripe-blocks,代码行数:11,代码来源:GridfieldConfig_BlockManager.php

示例14: OneBlock

 public function OneBlock($id)
 {
     return Block::get()->byID($id);
 }
开发者ID:Design-Collective,项目名称:Silverstripe-Content-Blocks,代码行数:4,代码来源:ContentBlocksModule.php

示例15: forTemplate

 function forTemplate()
 {
     $block = Block::get()->filter(['ID' => $this->BlockID])->first();
     return $this->renderWith([$block->Template, 'Block']);
     // Fall back to Block if selected does not exist
 }
开发者ID:kendu,项目名称:silverstripe-content-blocks,代码行数:6,代码来源:BlockTranslation.php


注:本文中的Block::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。