本文整理汇总了PHP中object::flush方法的典型用法代码示例。如果您正苦于以下问题:PHP object::flush方法的具体用法?PHP object::flush怎么用?PHP object::flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyLocaleData
public function copyLocaleData(LocaleInterface $sourceLocale, LocaleInterface $targetLocale)
{
$repositories = $this->getTranslatableRespositories();
$repositories->map(function (EntityRepository $repository) use($sourceLocale, $targetLocale) {
$this->copyTranslatableEntities($repository, $sourceLocale, $targetLocale);
});
$this->entityManager->flush();
}
示例2: set
public function set($configKey, $value)
{
$configItem = $this->get($configKey);
if (!$configItem) {
$configItem = ConfigItemFactory::createConfigItem($configKey, $value, $this->applicationId);
}
$this->_em->persist($configItem);
$this->_em->flush();
$this->_em->clear();
return $configItem;
}
示例3: setOauthCode
/**
* Sets oauth code to database.
* @param string $authCode
* @param object $client
* @return boolean
* @throws \Exception
*/
public function setOauthCode($authCode, $client)
{
$oauthCode = new OauthCode();
$oauthCode->setClient($client);
$oauthCode->setCode($authCode);
$oauthCode->setExpired('false');
try {
$this->em->persist($oauthCode);
$this->em->flush();
return true;
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage());
}
}
示例4: execute
public function execute()
{
/** @var Ticket $ticket */
$ticket = $this->context->getFact()->getTarget();
$branchId = $this->context->getParameters()->has('branch') ? $this->context->getParameters()->get('branch') : null;
if (is_null($branchId)) {
throw new \RuntimeException("Invalid rule configuration");
}
$branch = $this->em->getRepository('DiamanteDeskBundle:Branch')->get($branchId);
$ticket->move($branch);
$this->em->persist($ticket);
$this->em->flush();
$this->em->clear($ticket);
}
示例5: afterScenario
/**
* Listens to "scenario.after" and "outline.example.after" event.
*
* @param \Behat\Behat\Tester\Event\AbstractScenarioTested $event
*/
public function afterScenario(ScenarioTested $event)
{
if ('scenario' !== $this->lifetime) {
return;
}
$this->fixtureService->flush();
}
示例6: afterOutlineExample
/**
* Listens to "outline.example.after" event.
*
* @param \Behat\Behat\Event\OutlineExampleEvent $event
*/
public function afterOutlineExample(OutlineExampleEvent $event)
{
if ('scenario' !== $this->lifetime) {
return;
}
$this->fixtureService->flush();
}
示例7: authenticate
/**
* Performs an authentication attempt
*
* @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
* @return Zend_Auth_Result
*/
public function authenticate()
{
$user = $this->_em->getRepository($this->_model)->findOneBy(array('username' => $this->_username));
$result = array('code' => Zend_Auth_Result::FAILURE, 'identity' => array('username' => $this->_username), 'messages' => array());
if (!$user) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $result['identity'], $result['messages']);
}
$pwcheck = false;
if (!$this->_haveCookie) {
$pwcheck = OSS_Auth_Password::verify($this->_password, $user->getPassword(), $this->_aoptions);
if (!$pwcheck) {
if (method_exists($user, 'setFailedLogins')) {
$user->setFailedLogins($user->getFailedLogins() + 1);
$this->_em->flush();
$result['identity'] = array('count' => $user->getFailedLogins());
}
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $result['identity'], $result['messages']);
}
}
if ($pwcheck || $this->_haveCookie) {
$result['code'] = Zend_Auth_Result::SUCCESS;
$result['messages'] = array();
$result['identity'] = array('username' => $this->_username, 'user' => $user, 'id' => $user->getId());
} else {
die('Huh? This should not have happened....');
}
return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']);
}
示例8: getCache
/**
* Do any Page Caching if $this->cacheMethod is set.
* You should also look at output caching by overriding the outputBody Method.
*
* Note that Caching is disabled in a number of situations.
* a) cacheMethod is empty
* b) POST requests
* c) if sess is set (Eg. if you are using sessions)
* d) useCache is not set in the [Cache] section of the config.
*
* utilizes $this->getCacheID() to
*
* @return none|boolean|string|int|object Description
* @access public|private
* @see see also methods.....
*/
function getCache()
{
if (!$this->cacheMethod) {
return;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
return;
}
/* lets assume we can cache ourselves.. */
$coptions = PEAR::getStaticProperty('Cache', 'options');
if (!$coptions) {
return;
}
if (empty($coptions['useCache'])) {
return;
}
require_once 'Cache.php';
$this->_cache = new Cache($coptions['container'], $coptions);
$id = $this->_cache->generateID($this->getCacheID());
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->_cache->flush($id);
return;
}
if ($data = $this->_cache->get($id)) {
echo $data;
return TRUE;
}
}
示例9: delete
/**
* Deletes the specified cache or each one if '' given
*
* @param string $name cache name
*
* @return bool
*/
public function delete($name = '')
{
if ($name == '') {
return $this->provider->flush();
} else {
return $this->provider->delete($this->prefix . $name);
}
}
示例10: clean
/**
* Clean the Cache
*
* @return bool false on failure/true on success
*/
public function clean()
{
if ($this->is_supported()) {
return $this->_memcached->flush();
} else {
return FALSE;
}
}
示例11: deleteSaved
/**
* Delete all the saved models.
*
* @throws \League\FactoryMuffin\Exceptions\DeletingFailedException
*
* @return void
*/
public function deleteSaved()
{
parent::deleteSaved();
try {
$this->storage->flush();
} catch (\Exception $e) {
throw new DeletingFailedException([$e]);
}
}
示例12: clear_cache
/**
* Leerung des Cache
*
* @since 2.0.7
* @change 2.0.7
*/
public static function clear_cache()
{
/* Server connect */
if (!self::_connect_server()) {
return;
}
/* Flush */
@self::$_memcached->flush();
}
示例13: Clean
/**
* Set option
*
* @param $key
* @param $value
*/
public function Clean()
{
if (!$this->IsConnected)
$this->Connect();
if ($this->IsConnected)
return $this->MemCache->flush();
else
return false;
}
示例14: _write
/**
* The session save handler callback for writing data to the session.
*
* @param string $key The key of the data to be returned.
* @param mixed $value The value to be written to the session.
* @return boolean True if write was successful, false otherwise.
*/
public function _write($id, $data)
{
$expires = new \DateTime();
$expires->add(\DateInterval::createFromDateString($this->config['expiration']));
$this->record->setId($id);
$this->record->setData($data ?: null);
$this->record->setExpires($expires);
$this->entityManager->persist($this->record);
$this->entityManager->flush($this->record);
}
示例15: load
/**
* Load data fixtures with the passed EntityManager
*
* @param object $manager
*/
function load($manager)
{
foreach (range(0, 10) as $n) {
$feature = new Feature();
$feature->setName("feature-" . $n);
$feature->setDescription("feature-" . $n);
$feature->setProject($this->getReference('project-salgamos'));
$this->addReference('feature-' . $n, $feature);
$manager->persist($feature);
}
$manager->flush();
}