示例#1
0
 public function indexAction()
 {
     $this->name = $this->p('category', Setting_Category::first()->name);
     $this->current = Setting_Category::get($this->name);
     $this->settings = Setting::getCategory($this->name);
     $this->pageTitle = 'Settings: ' . $this->current->title;
 }
示例#2
0
 /**
  * @depends testAppendCategory
  */
 public function testLoadingCache()
 {
     $this->testAppendCategory();
     self::assertType('Setting_Category', Setting_Category::get('category 01'));
     self::assertType('Setting_Category', Setting_Category::get('category 02'));
     self::assertType('Setting_Category', Setting_Category::get('category 03'));
     self::assertException(function () {
         Setting_Category::get('');
     }, 'Nano_Exception', 'category "" not found');
     self::assertException(function () {
         Setting_Category::get('01');
     }, 'Nano_Exception', 'category "01" not found');
 }
示例#3
0
文件: Setting.php 项目: studio-v/nano
 /**
  * @return boolean
  * @param string $category
  * @param string $type
  * @param string $name
  * @param string $title
  * @param string $description
  * @param scalar $default
  * @param array $values
  */
 public static function append($category, $type, $name, $title, $description = null, $default = null, array $values = array())
 {
     try {
         $categoryId = Setting_Category::get($category)->setting_category_id;
         $setting = parent::create(__CLASS__, array('setting_category_id' => $categoryId, 'type' => $type, 'name' => $name, 'value' => null, 'title' => $title, 'description' => $description, 'default' => $default, 'values' => $values ? null : serialize($values), 'order' => self::getNexOrderValue($categoryId)));
         $setting->save();
         return true;
     } catch (Nano_Exception $e) {
         Nano_Log::message($e);
         return false;
     }
 }