本文整理汇总了PHP中object::create方法的典型用法代码示例。如果您正苦于以下问题:PHP object::create方法的具体用法?PHP object::create怎么用?PHP object::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Create new task and relation(s)
*
* @param CreateTaskRequest $request
*
* @return mixed
*/
public function store(CreateTaskRequest $request)
{
$input = $request->only('body', 'date', 'taskable');
$task = $this->task->create(['body' => $input['body'], 'date' => $input['date']]);
foreach ($input['taskable'] as $taskable => $id) {
$task->{$taskable}()->attach($id);
}
}
示例2: notify
/**
* Notifies about an alarm through Horde_Notification.
*
* @param array $alarm An alarm hash.
*/
public function notify(array $alarm)
{
$notification = $this->_notification->create();
$notification->push($alarm['title'], 'horde.alarm', array('alarm' => $alarm));
if (!empty($alarm['params']['notify']['sound']) && !isset($this->_soundPlayed[$alarm['params']['notify']['sound']])) {
$notification->attach('audio');
$notification->push($alarm['params']['notify']['sound'], 'audio');
$this->_soundPlayed[$alarm['params']['notify']['sound']] = true;
}
}
示例3: store
/**
* Create new comment and relation(s)
*
* @param CreateCommentRequest $request
*
* @return mixed
*/
public function store(CreateCommentRequest $request)
{
$input = $request->only('body', 'commentable');
$comment = $this->comment->create(['body' => $input['body']]);
foreach ($input['commentable'] as $commentable => $id) {
$comment->{$commentable}()->attach($id);
}
if (!$request->ajax()) {
return back();
}
}
示例4: setUp
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
global $g_ado_db;
$query = "DELETE FROM Languages WHERE Name = '" . $this->m_languageData['Name'] . "'";
$g_ado_db->Execute($query);
$this->m_languageObj = new Language();
$this->m_languageObj->create($this->m_languageData);
$this->m_metaLanguageObj = new MetaLanguage($this->m_languageObj->getLanguageId());
}
示例5: push
/**
* Push a message onto the end of the queue
*
* @param array $message
* @return mixed
*/
public function push($message)
{
$mid = $this->implement->create($message);
if ($mid === false || $this->implement->error()) {
$this->error = $this->implement->error();
return false;
}
if ($this->monitor->isReady()) {
$this->monitor->update();
}
return $mid;
}
示例6: execute
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
try {
$collection = $this->filter->getCollection($this->collectionFactory->create());
return $this->massAction($collection);
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setPath($this->redirectUrl);
}
}
示例7: sort
/**
* Sort by column
*
* @param string $name
* @param string $column
*
* @return response
*/
public function sort($name, $column)
{
if ($this->sorter->existsForLoggedUser($name)) {
$sorter = $this->sorter->getByNameAndLoggedUser($name);
if ($sorter->column == $column) {
$this->sorter->toggleDesc($sorter->id);
return redirect()->back();
}
$this->sorter->deleteByNameAndLoggedUser($name);
}
$this->sorter->create(['name' => $name, 'column' => $column]);
return redirect()->back();
}
示例8: create
/**
* Creates the cache file.
*
* @since 6.2.0
* @param int|string $key
* Unique key of the cache file.
* @param mixed $data
* Data that should be cached.
* @param string $namespace
* Optional. Where the cache contents are namespaced.
* @param int $ttl
* Time to live sets the life of the cache file.
*/
public function create($key, $data, $namespace = 'default', $ttl = 0)
{
if (empty($namespace)) {
$namespace = 'default';
}
return $this->_cache->create($key, $data, $namespace, (int) $ttl);
}
示例9: addToList
/**
* Find a Ip in the data source
*
* @param string $ip
* @return object|null
*/
public function addToList($whitelist, $ip)
{
$this->model->unguard();
$model = $this->model->create(array('ip_address' => $ip, 'whitelisted' => $whitelist));
$this->cacheRemember($model);
return $model;
}
示例10: import_tweet
protected function import_tweet(\stdClass $tweet)
{
$tweet = $this->get_real_tweet($tweet);
$this->post->set_tweet($tweet);
$post_id = $this->post->create();
return $post_id;
}
示例11: createEmailAlerts
/**
* @param $pageId
* @param $emails
*
* @return mixed
*/
public function createEmailAlerts($pageId, $emails)
{
$base_url = $this->url_components['server'] . $this->url_components['6.0'] . "profiles/%d/pages/%d/email_alerts";
$url = sprintf($base_url, $this->url_components['profiles'], $pageId);
$this->api->setupRequest($this->base_params['ACCESS_TOKEN'], $emails);
return $this->api->create($url);
}
示例12: _getUserInfo
/**
* Returns principal details.
*
* @param string $user A user name.
*
* @return array A hash with user information.
*/
protected function _getUserInfo($user)
{
if ($user == '-system-') {
return array('uri' => 'principals/-system-', '{DAV:}displayname' => Horde_Dav_Translation::t("System"));
}
$identity = $this->_identities->create($user);
return array('uri' => 'principals/' . $user, '{DAV:}displayname' => $identity->getName(), '{http://sabredav.org/ns}email-address' => (string) $identity->getDefaultFromAddress());
}
示例13: testBindingByName
public function testBindingByName()
{
$post = new Record(array('model' => $this->_model, 'data' => array('author_id' => '2', 'title' => 'New post', 'body' => 'New post body')));
$info = new Record(array('model' => $this->_model2, 'data' => array('section' => 'New post section', 'notes' => 'New post notes')));
$this->form->create(compact('post', 'info'));
$this->assertEqual($post, $this->form->binding('post'));
$this->assertEqual($info, $this->form->binding('info'));
}
示例14: sprintf
/**
* Event: new_faq
* Triggered after FAQ addition
* @param xhelpTicket $ticket Ticket used as base for FAQ
* @param xhelpFaq $faq FAQ that was added
*/
function new_faq($ticket, $faq)
{
global $xoopsUser;
$logMessage =& $this->_hLog->create();
$logMessage->setVar('uid', $xoopsUser->getVar('uid'));
$logMessage->setVar('ticketid', $ticket->getVar('id'));
$logMessage->setVar('action', sprintf(_XHELP_LOG_NEWFAQ, $faq->getVar('subject')));
return $this->_hLog->insert($logMessage, true);
}
示例15: testFormCreationWithNoContext
public function testFormCreationWithNoContext() {
$this->form = new Form(array('context' => new MockFormRenderer(array(
'request' => new Request(array('base' => '/bbq'))
))));
$result = $this->form->create(null, array('url' => '/foo'));
$this->assertTags($result, array('form' => array(
'action' => "/bbq/foo", 'method'=> "post"
)));
}