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


PHP Format::forge方法代码示例

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


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

示例1: action_add_blocked

 public function action_add_blocked($block = null)
 {
     if (empty($block) === true) {
         $block = $_POST['blocked'];
     } else {
         $block = str_replace('-', '.', $block);
     }
     $blacklist_item = Model_Blacklist::query()->where('expression', $block)->get_one();
     if (empty($blacklist_item) === true) {
         $blacklist_item = Model_Blacklist::forge(array('expression' => $block));
         $blacklist_item->save();
         if (Input::is_ajax() === true) {
             echo $blacklist_item->id;
         }
     } else {
         if (Input::is_ajax() === true) {
             print_r(Format::forge(array('error' => 'Already Exists'))->to_json());
         } else {
             Session::set('error', $block . ' is already in the blacklist!');
         }
     }
     if (Input::is_ajax() === true) {
         die;
     }
     Response::Redirect_Back();
 }
开发者ID:aircross,项目名称:MeeLa-Premium-URL-Shortener,代码行数:26,代码来源:admin.php

示例2: test__from_xml

    /**
     * Test for Format::forge($foo)->_from_xml()
     *
     * @test
     */
    public function test__from_xml()
    {
        $xml = '<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true" stopOnFailure="false" bootstrap="bootstrap_phpunit.php">
	<php>
		<server name="doc_root" value="../../"/>
		<server name="app_path" value="fuel/app"/>
		<server name="core_path" value="fuel/core"/>
		<server name="package_path" value="fuel/packages"/>
	</php>
	<testsuites>
		<testsuite name="core">
			<directory suffix=".php">../core/tests</directory>
		</testsuite>
		<testsuite name="packages">
			<directory suffix=".php">../packages/*/tests</directory>
		</testsuite>
		<testsuite name="app">
			<directory suffix=".php">../app/tests</directory>
		</testsuite>
	</testsuites>
</phpunit>';
        $expected = array('@attributes' => array('colors' => 'true', 'stopOnFailure' => 'false', 'bootstrap' => 'bootstrap_phpunit.php'), 'php' => array('server' => array(0 => array('@attributes' => array('name' => 'doc_root', 'value' => '../../')), 1 => array('@attributes' => array('name' => 'app_path', 'value' => 'fuel/app')), 2 => array('@attributes' => array('name' => 'core_path', 'value' => 'fuel/core')), 3 => array('@attributes' => array('name' => 'package_path', 'value' => 'fuel/packages')))), 'testsuites' => array('testsuite' => array(0 => array('@attributes' => array('name' => 'core'), 'directory' => '../core/tests'), 1 => array('@attributes' => array('name' => 'packages'), 'directory' => '../packages/*/tests'), 2 => array('@attributes' => array('name' => 'app'), 'directory' => '../app/tests'))));
        $this->assertEquals(Format::forge($expected)->to_php(), Format::forge($xml, 'xml')->to_php());
    }
开发者ID:phabos,项目名称:fuel-core,代码行数:31,代码来源:format.php

示例3: get_user_info

	public function get_user_info(Consumer $consumer, Token $token)
	{
		// Create a new GET request with the required parameters
		$url = 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url)';
		$request = Request::forge('resource', 'GET', $url, array(
			'oauth_consumer_key' => $consumer->key,
			'oauth_token' => $token->access_token,
		));

		// Sign the request using the consumer and token
		$request->sign($this->signature, $consumer, $token);
		
		$user = \Format::forge($request->execute(), 'xml')->to_array();
		
		// Create a response from the request
		return array(
			'uid' => $user['id'],
			'name' => $user['first-name'].' '.$user['last-name'],
			'nickname' => end(explode('/', $user['public-profile-url'])),
			'description' => $user['headline'],
			'location' => \Arr::get($user, 'location.name'),
			'urls' => array(
			  'Linked In' => $user['public-profile-url'],
			),
		);
	}
开发者ID:rob-mccann,项目名称:fuel-oauth,代码行数:26,代码来源:linkedin.php

示例4: createReferral

 public static function createReferral($data = array())
 {
     if (count($data) <= 0) {
         return;
     }
     $referralID = array();
     $referralID = \DB::query("INSERT INTO\n                                " . static::$tblReferrals . "\n                              (  id\n                                ,user_id\n                                ,introducer_id\n                                ,introducer_agent_name\n                                ,company_id\n                                ,product_id\n                                ,dialler_lead_id\n                                ,dialler_list_id\n                                ,dialler_list_name\n                                ,referral_date\n                                ,disposition_id\n                                ,title\n                                ,forename\n                                ,surname\n                                ,street_and_number\n                                ,area\n                                ,district\n                                ,town\n                                ,county\n                                ,country_id\n                                ,post_code\n                                ,date_of_birth\n                                ,tel_home\n                                ,tel_work\n                                ,tel_mobile\n                                ,email\n                                ,notes\n                                ,consolidation_centre )\n                              VALUES\n                              (  NULL\n                                ," . (isset($data['user_id']) ? (int) $data['user_id'] : 0) . "\n                                ," . (isset($data['introducer_id']) ? (int) $data['introducer_id'] : 0) . "\n                                ,'" . (isset($data['introducer_agent_name']) ? $data['introducer_agent_name'] : false) . "'\n                                ," . (isset($data['company_id']) ? (int) $data['company_id'] : 0) . "\n                                ," . (isset($data['product_id']) ? (int) $data['product_id'] : 0) . "\n                                ," . (isset($data['dialler_lead_id']) ? (int) $data['dialler_lead_id'] : 0) . "\n                                ," . (isset($data['dialler_list_id']) ? (int) $data['dialler_list_id'] : 0) . "\n                                ,'" . (isset($data['dialler_list_name']) ? $data['dialler_list_name'] : '') . "'\n                                ,NOW()\n                                ," . (int) $data['disposition_id'] . "\n                                ,'" . (isset($data['title']) ? $data['title'] : false) . "'\n                                ," . (isset($data['forename']) ? \DB::quote($data['forename']) : "''") . "\n                                ," . (isset($data['surname']) ? \DB::quote($data['surname']) : "''") . "\n                                ," . (isset($data['street_and_number']) ? \DB::quote($data['street_and_number']) : "''") . "\n                                ," . (isset($data['area']) ? \DB::quote($data['area']) : "''") . "\n                                ," . (isset($data['district']) ? \DB::quote($data['district']) : "''") . "\n                                ," . (isset($data['town']) ? \DB::quote($data['town']) : "''") . "\n                                ," . (isset($data['county']) ? \DB::quote($data['county']) : "''") . "\n                                ," . (isset($data['country_id']) ? (int) $data['country_id'] : 0) . "\n                                ," . (isset($data['post_code']) ? \DB::quote($data['post_code']) : "''") . "\n                                ,'" . (isset($data['date_of_birth']) ? $data['date_of_birth'] : 'NULL') . "'\n                                ," . ((int) isset($data['tel_home']) && $data['tel_home'] > 0 ? $data['tel_home'] : 0) . "\n                                ," . ((int) isset($data['tel_work']) && $data['tel_work'] > 0 ? $data['tel_work'] : 0) . "\n                                ," . ((int) isset($data['tel_mobile']) && $data['tel_mobile'] ? $data['tel_mobile'] : 0) . "\n                                ," . (isset($data['email']) ? \DB::quote($data['email']) : "''") . "\n                                ," . (isset($data['notes']) ? \DB::quote($data['notes']) : "''") . "\n                                ," . (isset($data['consolidation_centre']) ? (int) $data['consolidation_centre'] : 0) . ")\n                             ", \DB::insert())->execute();
     \Log::write('Dispo', \Format::forge($referralID)->to_json(), 'Referrals_model::createReferral()');
     \Log::write('Dispo', 'Referral created with the ID of ' . $referralID[0], 'Referrals_model::createReferral()');
     return $referralID[0];
 }
开发者ID:ClixLtd,项目名称:pccupload,代码行数:11,代码来源:referrals_model.php

示例5: response

 public function response()
 {
     if ($this instanceof HttpBadRequestException) {
         $this->message = 'Missing or Invalid Parameter(s): ' . $this->getMessage();
     }
     $response = null;
     if ($this->getMessage()) {
         $data = array('message' => $this->getMessage());
         $response = \Format::forge($data)->to_json();
     }
     return new \Response($response, $this->getCode());
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:12,代码来源:httpexceptions.php

示例6: run

 /**
  * manage and execute queues
  *
  */
 public function run()
 {
     // check pids
     if (\Config::get('queue.queue_parallel_number') <= count(glob(\APPPATH . 'tmp/' . \Config::get('queue.queue_pid_prefix') . '_*.pid'))) {
         \Log::debug('queue limit over.');
         return;
     }
     $this->__process_file_name = \Config::get('queue.queue_pid_prefix') . '_' . getmypid() . '.pid';
     // create pid file
     \File::create(\APPPATH . 'tmp', $this->__process_file_name);
     try {
         // check dead queues
         $recover = \Model_TaskQueue::recover_zombie_queues();
         if (!empty($recover)) {
             \Model_TaskQueue::notify('zombie task recovered. ids = ' . implode(',', $recover));
         }
         // check queues
         $queue = \Model_TaskQueue::pickup();
         if (empty($queue)) {
             return;
         }
         // exec queue
         call_user_func_array('\\' . $queue['method'], \Format::forge($queue['options'], 'json')->to_array());
         // finish (update to success) queue
         \Model_TaskQueue::finish($queue['id'], \Model_TaskQueue::STATUS_SUCCESS);
     } catch (\Exception $e) {
         if (\DB::in_transaction()) {
             \DB::rollback_transaction();
         }
         if (isset($queue) and !empty($queue)) {
             // finish (update to error) queue
             \Model_TaskQueue::finish($queue['id'], \Model_TaskQueue::STATUS_ERROR);
             // send to notify method
             $body = array();
             $body[] = 'task queue error occured.';
             $body[] = '--------------------------------';
             $body[] = 'id: ' . $queue['id'];
             $body[] = 'method: ' . $queue['method'];
             $body[] = 'options: ' . $queue['options'];
             if (is_array($e->getMessage())) {
                 $body[] = 'reason: ' . implode(' ', $e->getMessage());
             } elseif (!empty($e->getMessage())) {
                 $body[] = 'reason: ' . $e->getMessage();
             }
             \Model_TaskQueue::notify($body);
         }
     } finally {
         \File::delete(\APPPATH . 'tmp/' . $this->__process_file_name);
     }
 }
开发者ID:hinashiki,项目名称:fuelphp-queue,代码行数:54,代码来源:queues.php

示例7: action_index

 /**
  * Returns a list of event agenda items.
  * The method is mainly intended to be called using ajax
  * in this case, a json-formated string is returned.
  * @param int $event_id
  */
 public function action_index($event_id = null)
 {
     !isset($event_id) and Response::redirect("event");
     $event = Model_Orm_Event::find($event_id, array("related" => array("agendas")));
     !isset($event) and Response::redirect("event");
     if (Input::is_ajax()) {
         $response = Response::forge(Format::forge()->to_json($event->agendas));
         $response->set_header("Content-Type", "application/json");
         return $response;
     } else {
         $data['event'] = $event;
         $this->template->title = "Agenda items: " . $event->title;
         $this->template->content = View::forge('agenda/index', $data);
     }
 }
开发者ID:beingsane,项目名称:TTII_2012,代码行数:21,代码来源:agenda.php

示例8: action_create

 public function action_create()
 {
     //assumption: this will only be called using ajax
     if (!Input::is_ajax()) {
         return Response::forge("Access forbidden, only AJAX calls allowed", 403);
     }
     if (!Auth::has_access("location.create")) {
         return Response::forge("Only admins allowed here", 403);
     }
     if (Input::post("location_title", null) != null) {
         $loc = Model_Orm_Location::forge();
         $loc->title = Input::post("location_title");
         $loc->save();
         $ret = array("id" => $loc->id);
         return Response::forge(Format::forge()->to_json($ret), 200, array("Content-Type" => "application/json"));
     }
 }
开发者ID:beingsane,项目名称:TTII_2012,代码行数:17,代码来源:location.php

示例9: get_validate

 public function get_validate($apiKey = null)
 {
     $apiCheck = \Crm\Portal\Portal_Check::api_key($apiKey);
     if ($apiCheck === false) {
         $this->response(array('status' => 'FAIL', 'message' => 'Invalid API Key has been used, please contact your IT support!'));
     } else {
         $allFields = TRUE;
         $missingFields = array();
         $surveyChoice = $apiCheck->survey;
         $surveyQuestions = \Model_Survey_Question::query()->where('survey_id', $surveyChoice)->where('required', '1')->get();
         $allSurveyQuestions = \Model_Survey_Question::query()->where('survey_id', $surveyChoice)->get();
         foreach ($surveyQuestions as $surveyRequired) {
             $requiredFields[] = 'form-q' . $surveyRequired->id;
         }
         foreach ($allSurveyQuestions as $surveyQuestions) {
             $questionFields[] = 'form-q' . $surveyQuestions->id;
         }
         // Check and make a list of any missing fields
         foreach ($requiredFields as $field) {
             if (is_null(Input::get($field, null)) || strlen(Input::get($field, null)) < 1 && !is_integer(Input::get($field, null)) || Input::get($field, null) == "-- Select") {
                 $allFields = FALSE;
                 $missingFields[] = $field;
             }
         }
         // If we have everything we need then we do our logic
         if ($allFields) {
             // Get the client type from the given questions
             $questionPassOn = array();
             foreach ($questionFields as $singleQuestion) {
                 $questionPassOn[$singleQuestion] = Input::get($singleQuestion, null);
                 $questionPassOn[str_replace('form-q', 'form-e', $singleQuestion)] = Input::get(str_replace('form-q', 'form-e', $singleQuestion), null);
             }
             \log::write('PPI-DEBUG', \Format::forge($_GET)->to_json());
             $clientType = \Crm\Portal\Portal_Check::choice($questionPassOn, $_GET, $apiKey);
             // If we can decide on a client type
             if (!is_null($clientType)) {
                 $this->response(array('client_type' => $clientType));
             } else {
                 $this->response(array('status' => 'FAIL', 'message' => 'No client type could be decided. Please complete ALL the given questions.'));
             }
         } else {
             $this->response(array('status' => 'FAIL', 'code' => '101', 'message' => 'Not all required fields were submitted! Missing fields are ' . implode(", ", $missingFields), 'missing_fields' => $missingFields));
         }
     }
 }
开发者ID:ClixLtd,项目名称:pccupload,代码行数:45,代码来源:portal.php

示例10: load

 public static function load($table, $file)
 {
     $fixt_name = $file . '_fixt';
     $file_name = $fixt_name . '.' . static::$file_ext;
     $fixt_file = APPPATH . 'tests/fixture/' . $file_name;
     if (!file_exists($fixt_file)) {
         exit('No such file: ' . $fixt_file . PHP_EOL);
     }
     // フィクスチャファイルを読み込んで配列に変換
     $data = file_get_contents($fixt_file);
     $data = Format::forge($data, static::$file_type)->to_array();
     // テーブルのデータを削除
     static::empty_table($table);
     // フィクスチャデータの挿入
     foreach ($data as $row) {
         list($insert_id, $rows_affected) = DB::insert($table)->set($row)->execute();
     }
     Log::info('Table Fixture ' . $file_name . ' -> ' . $fixt_name . ' loaded', __METHOD__);
     return $data;
 }
开发者ID:sato5603,项目名称:fuelphp1st-2nd,代码行数:20,代码来源:dbfixture.php

示例11: test_to_array_empty

 function test_to_array_empty()
 {
     $array = null;
     $expected = array();
     $this->assertEquals($expected, Format::forge($array)->to_array());
 }
开发者ID:cloudetm,项目名称:development,代码行数:6,代码来源:format.php

示例12: set_response

 /**
  * Creates the Response and optionally attempts to auto-format the output
  *
  * @param   string  $body
  * @param   int     $status
  * @param   string  $mime
  * @param   array   $headers
  * @return  Response
  */
 public function set_response($body, $status, $mime = null, $headers = array())
 {
     if ($this->auto_format and array_key_exists($mime, static::$auto_detect_formats)) {
         $body = \Format::forge($body, static::$auto_detect_formats[$mime])->to_array();
     }
     $this->response = \Response::forge($body, $status, $headers);
     return $this->response;
 }
开发者ID:rickmellor,项目名称:Infrastructure,代码行数:17,代码来源:driver.php

示例13: test_to_xml_cdata

    /**
     * Test for Format::forge($foo)->to_xml(null, null, 'xml', true)
     *
     * @test
     */
    public function test_to_xml_cdata()
    {
        $array = array('articles' => array(array('title' => 'test', 'author' => '<h1>hero</h1>')));
        $expected = '<?xml version="1.0" encoding="utf-8"?>
<xml><articles><article><title>test</title><author><![CDATA[<h1>hero</h1>]]></author></article></articles></xml>
';
        $this->assertEquals($expected, Format::forge($array)->to_xml(null, null, 'xml', true));
    }
开发者ID:marietta-adachi,项目名称:website,代码行数:13,代码来源:format.php

示例14: response_csv

 /**
  * CSV出力
  *
  * @access public
  * @param
  * @return void
  * @author kobayashi
  * @author ida
  */
 protected function response_csv($data, $fleamarket_name)
 {
     $csv = mb_convert_encoding(Format::forge($data)->to_csv(), 'SJIS-win', 'UTF-8');
     $file_name = $fleamarket_name . '_エントリ一覧.csv';
     $response = new Response($csv, 200, array('Content-Type' => 'application/csv', 'Content-Disposition' => 'attachment; filename="' . $file_name . '"'));
     return $response;
 }
开发者ID:eva-tuantran,项目名称:use-knife-solo-instead-chef-solo-day13,代码行数:16,代码来源:entry.php

示例15: fetch_rules

 protected function fetch_rules()
 {
     // set rules array
     $rules = array();
     // get permissions file config options
     $permission_file = Config::get('sentry.permissions.file');
     // load global rules
     $rules = Config::get('sentry.permissions.rules');
     // see if we should use config files or not
     if ($permission_file['name'] == 'config' or empty($permission_file['name']) or $permission_file['name'] == null) {
         // load current module specific rules if a module is active
         if (isset(\Request::active()->module)) {
             \Config::load(\Request::active()->module, true);
             $module_permissions = Config::get(\Request::active()->module . '.rules');
             if (!empty($module_permissions)) {
                 $rules = Arr::merge($rules, $module_permissions);
             }
         }
         return $rules;
     }
     // loop through module paths and see if listed file exists
     $file = false;
     foreach (Config::get('module_paths') as $path) {
         $path = $path . \Request::active()->module . DS;
         if (!empty($permission_file['path'])) {
             $path .= $permission_file['path'] . DS . $permission_file['name'];
         } else {
             $path .= $permission_file['name'];
         }
         if (file_exists($path)) {
             $file = $path;
             break;
         }
     }
     // if the file exists pull in rules if they are set
     if ($file) {
         // get file type
         switch ($permission_file['type']) {
             case 'ini':
                 $info = parse_ini_file($file, true);
                 break;
             case 'json':
                 $info = json_decode(file_get_contents($file), true);
                 break;
             case 'yaml':
                 $info = \Format::forge(file_get_contents($file), 'yaml')->to_array();
                 break;
             case 'php':
                 $info = (include $file);
                 break;
             default:
                 // move this somewhere else for easier debugging?
                 throw new \SentryUserException(sprintf('Invalid permission file type "%s".', $type));
         }
         // now set rules if they exist
         if (isset($info['rules'])) {
             $rules = $info['rules'];
         }
     }
     return $rules;
 }
开发者ID:roine,项目名称:wawaw,代码行数:61,代码来源:user.php


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