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


PHP eden函数代码示例

本文整理汇总了PHP中eden函数的典型用法代码示例。如果您正苦于以下问题:PHP eden函数的具体用法?PHP eden怎么用?PHP eden使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: touch

 public function touch()
 {
     $class = eden('system')->file(realpath(__DIR__ . '/../assets') . '/content.txt')->touch();
     $this->assertInstanceOf('Eden\\System\\File', $class);
     $this->assertTrue(file_exists(__DIR__ . '/../assets/content.txt'));
     eden('system')->file(realpath(__DIR__ . '/../assets') . '/content.txt')->remove();
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:7,代码来源:FileTest.php

示例2: testArrayAccess

 public function testArrayAccess()
 {
     $path = eden('system')->path('some/path/');
     $this->assertEquals('some', $path[1]);
     $path['replace'] = 'foo';
     $this->assertEquals('foo', $path['last']);
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:7,代码来源:PathTest.php

示例3: testImport

 public function testImport()
 {
     $callback = Eve\Plugin\Csrf\Setup::i()->import();
     $this->assertTrue(is_callable($callback));
     $error = false;
     try {
         eve()->addCsrf(eden('registry'), eden('registry'), array('method' => 'GET', 'check_csrf' => true));
     } catch (Exception $e) {
         $error = true;
     }
     $this->assertTrue($error);
     $error = false;
     $request = eden('registry')->set('get', 'csrf', '1234567890');
     try {
         eve()->addCsrf($request, eden('registry'), array('method' => 'GET', 'check_csrf' => true, 'make_csrf' => true));
     } catch (Exception $e) {
         $error = true;
     }
     $this->assertFalse($error);
     $this->assertTrue($request->get('get', 'csrf') !== $request->get('csrf'));
     $_GET['csrf'] = $_SESSION['csrf'] = $request->get('csrf');
     $error = false;
     try {
         $callback($request, eden('registry'));
     } catch (Exception $e) {
         $error = true;
     }
     $this->assertFalse($error);
 }
开发者ID:eve-php,项目名称:eve-plugin-csrf,代码行数:29,代码来源:Setup.php

示例4: testIterable

 public function testIterable()
 {
     $data = array('foo', 'bar');
     $class = eden('type', $data);
     foreach ($class as $key => $value) {
         $this->assertEquals($class->current(), $value);
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:8,代码来源:ArrayTypeTest.php

示例5: testUncamelize

 public function testUncamelize()
 {
     $string = 'testValue';
     $resultString = 'test-value';
     $class = eden('type', $string)->uncamelize('-');
     $this->assertInstanceOf('Eden\\Type\\StringType', $class);
     $newString = $class->get();
     $this->assertEquals($resultString, $newString);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:9,代码来源:StringTypeTest.php

示例6: testIterable

 public function testIterable()
 {
     $class = @eden('session')->start();
     $class['me'] = array('name' => 'John', 'age' => 31);
     $class['you'] = array('name' => 'Jane', 'age' => 28);
     $class['him'] = array('name' => 'Jack', 'age' => 35);
     foreach ($class as $key => $value) {
         $this->assertEquals($class[$key]['name'], $value['name']);
     }
 }
开发者ID:Eden-PHP,项目名称:Session,代码行数:10,代码来源:Index.php

示例7: _getContents

 protected function _getContents($path)
 {
     try {
         $library = front()->registry()->get('path', 'library');
         $folder = eden('folder', $library . $path);
         $files = $folder->getFiles();
         $folders = $folder->getFolders();
     } catch (Exception $e) {
         return array('folders' => array(), 'files' => array());
     }
     sort($files);
     sort($folders);
     return array('folders' => $folders, 'files' => $files);
 }
开发者ID:jpalala,项目名称:startupjobs,代码行数:14,代码来源:menu.php

示例8: testAddRoute

 public function testAddRoute()
 {
     $rest = eden('rest', 'http://graph.facebook.com', true)->addRoute('create/wall/post', 'create/post')->addRoute('create/page/post', 'create/post')->addRoute('create/group/post', 'create/post')->addRoute('create/event/post', 'create/post')->addRoute('create/post', array('method' => 'post', 'route' => '/*/feed', 'data' => array('tags' => array(array('regex', '/^[0-9\\,]+$/')), 'access_token' => 'required', 'privacy' => 'json'), 'error' => array('tags' => 'tags must be a list of user ids', 'access_token' => 'access_token is required'), 'query' => array('access_token'), 'request' => 'query', 'response' => 'json'));
     //test pathing
     $meta = $rest->setAccessToken('123')->setTags('123,234')->createPost(345);
     $this->assertEquals('http://graph.facebook.com/345/feed?access_token=123', $meta['url']);
     $this->assertEquals(http_build_query(array('tags' => '123,234')), $meta['post']);
     //test alias
     $meta = $rest->createWallPost(345);
     $this->assertEquals('http://graph.facebook.com/345/feed?access_token=123', $meta['url']);
     $this->assertEquals(http_build_query(array('tags' => '123,234')), $meta['post']);
     //test extra
     $meta = $rest->createPagePost(345, 456);
     $this->assertEquals('http://graph.facebook.com/345/feed?access_token=123', $meta['url']);
     $this->assertEquals(http_build_query(array('tags' => '123,234')), $meta['post']);
 }
开发者ID:Eden-PHP,项目名称:Rest,代码行数:16,代码来源:Index.php

示例9: testImport

 public function testImport()
 {
     $callback = Eve\Plugin\Captcha\Setup::i()->import('123', '321');
     $this->assertTrue(is_callable($callback));
     $request = eden('registry');
     eve()->addCaptcha($request, eden('registry'), array('method' => 'GET', 'check_captcha' => true));
     $this->assertFalse($request->get('valid_captcha'));
     $request->set('valid_captcha', true);
     $request->set('get', 'g-recaptcha-response', '1234567890');
     eve()->addCaptcha($request, eden('registry'), array('method' => 'GET', 'check_captcha' => true, 'make_captcha' => true));
     $this->assertTrue($request->get('valid_captcha') !== false);
     $_GET['g-recaptcha-response'] = $_SESSION['captcha'] = $request->get('csrf');
     $error = false;
     try {
         $callback($request, eden('registry'));
     } catch (Exception $e) {
         $error = true;
     }
     $this->assertFalse($error);
 }
开发者ID:eve-php,项目名称:eve-plugin-captcha,代码行数:20,代码来源:Setup.php

示例10: import

 /**
  * Main route method
  *
  * @return function
  */
 public function import($token, $secret, $escape = '1234567890')
 {
     Argument::i()->test(1, 'string')->test(2, 'string')->test(3, 'string');
     //remember this scope
     $self = $this;
     eve()->addMethod('addCaptcha', function (Registry $request, Registry $response, array $meta) use($token, $self) {
         //we already checked the captcha it's good
         //we just need to check if it's set
         if (isset($meta['check_captcha']) && $meta['check_captcha'] && !$request->isKey('get', 'g-recaptcha-response') && !$request->isKey('post', 'g-recaptcha-response')) {
             //let the action handle the rest
             $request->set('valid_captcha', false);
         }
         //set captcha
         if (isset($route['make_captcha']) && $meta['make_captcha']) {
             $request->set('captcha', $token);
         }
     });
     //You can add validators here
     return function (Registry $request, Registry $response) use($secret, $escape, $self) {
         $request->set('valid_captcha', true);
         //CAPTCHA - whether or not we are expecting it lets do a check
         $captcha = false;
         if ($request->isKey('get', 'g-recaptcha-response')) {
             $captcha = $request->get('get', 'g-recaptcha-response');
         } else {
             if ($request->isKey('post', 'g-recaptcha-response')) {
                 $captcha = $request->get('post', 'g-recaptcha-response');
             }
         }
         if ($captcha !== false && $captcha !== $escape) {
             $result = eden('curl')->setUrl('https://www.google.com/recaptcha/api/siteverify')->verifyHost(false)->verifyPeer(false)->setPostFields(http_build_query(array('secret' => $secret, 'response' => $captcha)))->getJsonResponse();
             //let the action handle the rest
             $request->set('valid_captcha', $result['success']);
         }
     };
 }
开发者ID:eve-php,项目名称:eve-plugin-captcha,代码行数:41,代码来源:Setup.php

示例11: sendEmail

 /**
  * send email template
  *
  * @param string
  * @param array
  * @param array
  */
 protected function sendEmail($subject, $to, $vars)
 {
     //set email account
     $smtp = eden('mail')->smtp('smtp.gmail.com', self::EMAIL, self::PASSWORD, 465, true);
     //parse the template with its variables
     $message = control()->template($this->emailTemp, $vars);
     //now send the parsed message to the user's email
     $smtp->setSubject($subject)->setBody($message, true);
     foreach ($to as $email) {
         $smtp->addTo($email);
     }
     return $smtp->send();
 }
开发者ID:rujealfon,项目名称:UAC,代码行数:20,代码来源:Page.php

示例12: eden

if ($getUser->num_rows == 0) {
    //new user
    if (!isset($_SESSION['access_token'], $_SESSION['access_secret'])) {
        if (!isset($_SESSION['request_secret'])) {
            $token = $auth->getRequestToken();
            $_SESSION['request_secret'] = $token['oauth_token_secret'];
            $login = $auth->getLoginUrl($token['oauth_token'], 'http://goo.gl');
            $_SESSION['twitter_login'] = $login;
        }
        if (isset($_GET['oauth_token'], $_GET['oauth_verifier'])) {
            $token = $auth->getAccessToken($_GET['oauth_token'], $_SESSION['request_secret'], $_GET['oauth_verifier']);
            $_SESSION['access_token'] = $token['oauth_token'];
            $_SESSION['access_secret'] = $token['oauth_token_secret'];
            $user_token = $_SESSION['access_token'];
            $user_secret = $_SESSION['access_secret'];
            $users = eden('twitter')->users(TWITTER_TOKEN, TWITTER_SECRET, $user_token, $user_secret);
            $user_info = $users->getCredentials();
            $username = $user_info['screen_name'];
            $oauth_id = $user_info['id'];
            //newly connected twitter account
            $db->query("\n\t\t\t\tINSERT INTO tbl_oauth SET oauth_token = '{$user_token}', \n\t\t\t\toauth_secret = '{$user_secret}', oauth_id = '{$oauth_id}', provider = 'twitter',\n\t\t\t\tuser_id = '{$user_id}', username = '{$username}'\n\t\t\t");
            unset($_SESSION['request_secret']);
        }
    }
} else {
    $user_data = $getUser->fetch_object();
    $_SESSION['access_token'] = $user_data->oauth_token;
    $_SESSION['access_secret'] = $user_data->oauth_secret;
}
?>
	<body>
开发者ID:brynner,项目名称:postr,代码行数:31,代码来源:postr.php

示例13: getSlug

 /**
  * Returns a generated slug, considering duplicates
  *
  * @param string
  * @return string
  */
 public function getSlug($name)
 {
     $slug = (string) eden('type', $name)->dasherize();
     $join = $filter = $sort = array();
     //SELECT * FROM `post` WHERE post_slug RLIKE '^test\-title\-[0-9]+$' ORDER BY post_slug DESC
     $filter[] = array('user_slug=%s OR user_slug RLIKE %s', $slug, '^' . str_replace('-', '\\-', $slug) . '-[0-9]+$');
     $sort = array('user_id' => 'DESC');
     $user = $this->_database->getRows('user', $join, $filter, $sort, 0, 1, 0);
     if (empty($user)) {
         return $slug;
     }
     $count = substr($user['user_slug'], strlen($slug) + 1);
     $slug .= '-' . (is_numeric($count) ? $count + 1 : 1);
     return $slug;
 }
开发者ID:jpalala,项目名称:startupjobs,代码行数:21,代码来源:user.php

示例14: testWhen

 public function testWhen()
 {
     $test = 'Good';
     eden()->when(function () {
         return false;
     }, function () use(&$test) {
         $test = 'Bad';
     });
     $this->assertSame('Good', $test);
     $test = 'Good';
     eden()->when(null, function () use(&$test) {
         $test = 'Bad';
     });
     $this->assertSame('Good', $test);
     $test = 'Good';
     eden()->when(false, function () use(&$test) {
         $test = 'Bad';
     });
     $this->assertSame('Good', $test);
     $test = 'Good';
     eden()->when(function () {
         return true;
     }, function () use(&$test) {
         $test = 'Bad';
     });
     $this->assertSame('Bad', $test);
     $test = 'Good';
     eden()->when('hi', function () use(&$test) {
         $test = 'Bad';
     });
     $this->assertSame('Bad', $test);
     $test = 'Good';
     eden()->when(true, function () use(&$test) {
         $test = 'Bad';
     });
     $this->assertSame('Bad', $test);
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:37,代码来源:BaseTest.php

示例15: testRelease

 public function testRelease()
 {
     $route = eden('core')->route()->release('test');
     $this->assertFalse($route->valid('test'));
 }
开发者ID:eden-php,项目名称:core,代码行数:5,代码来源:Route.php


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