本文整理汇总了PHP中Doctrine_Event类的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Event类的具体用法?PHP Doctrine_Event怎么用?PHP Doctrine_Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Doctrine_Event类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _createOperationLog
/**
* Creates a new logging instance.
*
* @param Doctrine_Event $event Event.
* @param int $opType I/U/D for Insert/Update/Delete.
*
* @return void
*/
private function _createOperationLog(Doctrine_Event $event, $opType = 'I')
{
$data = $event->getInvoker();
$tableName = $this->getTableNameFromEvent($event);
$idColumn = $this->getIdColumnFromEvent($event);
$log = array();
$log['object_type'] = $tableName;
$log['object_id'] = $data[$idColumn];
$log['op'] = $opType;
if ($opType == 'U') {
$oldValues = $data->getLastModified(true);
$diff = array();
foreach ($oldValues as $column => $oldValue) {
if (empty($oldValue) && isset($data[$column]) && !empty($data[$column])) {
$diff[$column] = 'I: ' . $data[$column];
} elseif (!empty($oldValue) && isset($data[$column]) && !empty($data[$column])) {
$diff[$column] = 'U: ' . $data[$column];
} elseif (!empty($oldValue) && empty($data[$column])) {
$diff[$column] = 'D: ' . $oldValue;
}
}
$log['diff'] = serialize($diff);
} else {
// Convert object to array (otherwise we serialize the record object)
$log['diff'] = serialize($data->toArray());
}
DBUtil::insertObject($log, 'objectdata_log');
}
开发者ID:Silwereth,项目名称:core,代码行数:36,代码来源:Logging.php
示例2: preStmtExecute
public function preStmtExecute(Doctrine_Event $event)
{
// Check if the administrator has enabled the query logging feature
if (Settings::findbyParam('debug_queries')) {
$breadcrumps = array();
$query = $event->getQuery();
$params = $event->getParams();
$callers = array_reverse(debug_backtrace(), true);
$callers = array_slice($callers, 4, count($callers) - 10);
foreach ($callers as $caller) {
$class = !empty($caller['class']) ? $caller['class'] : null;
$breadcrumps[] = $class . "->" . $caller['function'];
}
$strBreadcrump = "System: " . implode(" / ", $breadcrumps);
//the below makes some naive assumptions about the queries being logged
while (sizeof($params) > 0) {
$param = array_shift($params);
if (!is_numeric($param)) {
$param = sprintf("'%s'", $param);
}
$query = substr_replace($query, $param, strpos($query, '?'), 1);
}
Shineisp_Commons_Utilities::log($query, "queries.log");
Shineisp_Commons_Utilities::log($strBreadcrump, "debug.log", Zend_Log::DEBUG);
// Increase query counter
$queryCount = Shineisp_Registry::isRegistered('querycount') ? Shineisp_Registry::get('querycount') : 0;
$queryCount = $queryCount + 1;
Shineisp_Registry::set('querycount', $queryCount);
}
}
开发者ID:kokkez,项目名称:shineisp,代码行数:30,代码来源:QueriesLogger.php
示例3: preUpdate
/**
* @param Doctrine_Event $event
*/
public function preUpdate(Doctrine_Event $event)
{
$record = $event->getInvoker();
$modified = $record->getModified();
$original = $record->getModified(true);
foreach ($this->Slices as &$slice) {
if (array_key_exists('title', $modified)) {
if ($slice->title == $original['title'] || $slice->title == null) {
$slice->title = $modified['title'];
}
}
if (array_key_exists('slug', $modified)) {
if ($slice->slug == $original['slug'] || $slice->slug == null) {
$slice->slug = $modified['slug'];
}
}
if (array_key_exists('description', $modified)) {
if ($slice->caption == $original['description'] || $slice->caption == null) {
$slice->caption = $modified['description'];
}
}
if (array_key_exists('published', $modified) && $modified['published'] == false && $original['published'] == true) {
$slice->published = false;
}
if (array_key_exists('published', $modified) && $modified['published'] == true && $original['published'] == false && RokGallery_Config::getOption(RokGallery_Config::OPTION_SLICE_AUTOPUBLISH_ON_FILE_PUBLISH, false)) {
$slice->published = true;
}
}
if (array_key_exists('manipulations', $modified)) {
$this->processImages();
}
}
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:35,代码来源:File.php
示例4: preDqlDelete
public function preDqlDelete(Doctrine_Event $event)
{
$params = $event->getParams();
$tmpQuery = clone $event->getQuery();
$subQuery = $tmpQuery->select($params['alias'] . '.' . $params['component']['table']->getIdentifier())->getDql();
if (!in_array($params['alias'], $tmpQuery->getDqlPart('from'))) {
return false;
}
$targets = $this->detectCascadingTargets($params['component']['table']);
foreach ($targets as $target) {
$table = Doctrine::getTable($target['table']);
$relation = $table->getRelation($target['aliasFrom']);
$localField = $relation->getLocalFieldName();
$q = $table->createQuery();
$q = $q->where($q->getRootAlias() . '.' . $localField . ' IN (' . $subQuery . ')');
switch (strtolower($target['delete'])) {
case 'cascade':
$q->delete()->execute();
break;
case 'set null':
$q->update()->set($localField, '?', array(null))->execute();
break;
default:
// do nothing
}
}
}
开发者ID:phenom,项目名称:OpenPNE3,代码行数:27,代码来源:opApplicationLevelCascadingListener.class.php
示例5: preUpdate
/**
* preUpdate
*
* @param object $Doctrine_Event
* @return void
*/
public function preUpdate(Doctrine_Event $event)
{
if (!$this->_options['updated']['disabled']) {
$updatedName = $this->_options['updated']['name'];
$event->getInvoker()->{$updatedName} = $this->getTimestamp('updated');
}
}
开发者ID:kirvin,项目名称:the-nerdery,代码行数:13,代码来源:Timestampable.php
示例6: preSave
/**
* Throws an exception if the record is modified while it is
* locked.
*
* @param Doctrine_Event $event
* @return void
*/
public function preSave(Doctrine_Event $event)
{
$modelName = Doctrine_Inflector::tableize(get_class($event->getInvoker()));
$modifiedFields = $event->getInvoker()->getModified();
$locked = $event->getInvoker()->isLocked;
$lockModified = array_key_exists('isLocked', $modifiedFields);
$numModified = count($modifiedFields);
/**
* Record fields haven't been modified, nothing to do here.
*/
if (!$event->getInvoker()->isModified()) {
return;
}
/**
* The record is not locked, and the lock isn't being changed, nothing to do here.
*/
if (!$locked && !$lockModified) {
return;
}
/**
* Only the lock is being modified so there's nothing to
* do here.
*/
if ($lockModified && $numModified == 1) {
return;
}
/**
* The record is locked, throw an exception.
*/
if ($locked) {
throw new Behavior_Lockable_Exception('The record must be unlocked before it can be modified.');
}
}
开发者ID:boydjd,项目名称:doctrine-addons,代码行数:40,代码来源:Listener.php
示例7: preSave
/**
* Pre-save logic.
*
* Use preSave instead of preUpdate since the latter depends on the record's
* state, which isn't necessarily dirty.
*
* @see Doctrine_Record_Listener
*/
public function preSave(Doctrine_Event $event)
{
// loop through relations
if ($relations = $this->form->getOption('dynamic_relations')) {
foreach ($relations as $field => $config) {
// collect form objects for comparison
$search = array();
foreach ($this->form->getEmbeddedForm($field)->getEmbeddedForms() as $embed) {
$search[] = $embed->getObject();
}
$collection = $event->getInvoker()->get($config['relation']->getAlias());
foreach ($collection as $i => $object) {
if (false === ($pos = array_search($object, $search, true))) {
// if a related object exists in the record but isn't represented
// in the form, the reference has been removed
$collection->remove($i);
// if the foreign column is a notnull columns, delete the object
$column = $config['relation']->getTable()->getColumnDefinition($config['relation']->getForeignColumnName());
if ($object->exists() && isset($column['notnull']) && $column['notnull']) {
$object->delete();
}
}
}
}
}
}
开发者ID:kriswallsmith,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:34,代码来源:sfDoctrineDynamicFormRelationsListener.class.php
示例8: preUpdate
/**
* Pre update event hook for inserting new version record
* This will only insert a version record if the auditLog is enabled
*
* @param Doctrine_Event $event
* @return void
*/
public function preUpdate(Doctrine_Event $event)
{
$disabled = $event->getInvoker()->hasMappedValue('disable_versioning') ? $event->getInvoker()->get('disable_versioning') : false;
if (!$disabled) {
parent::preUpdate($event);
}
}
开发者ID:theolymp,项目名称:diem,代码行数:14,代码来源:Listener.php
示例9: __construct
public function __construct(Doctrine_Event $event, $when, $action, $parameters = array())
{
$invoker = $event->getInvoker();
$parameters['record'] = $invoker;
parent::__construct($invoker, sprintf('op_doctrine.%s_%s_%s', $when, $action, get_class($invoker)), $parameters);
$this->doctrineEvent = $event;
}
开发者ID:te-koyama,项目名称:openpne,代码行数:7,代码来源:opDoctrineEvent.class.php
示例10: preSave
public function preSave(Doctrine_Event $event)
{
$invoker = $event->getInvoker();
$template = $invoker->getTable()->getTemplate('Doctrine_Template_GoogleI18n');
$options = $template->getOptions();
// get the first langauge that was changed
foreach ($invoker->Translation as $lang => $translation) {
if ($translation->isModified()) {
$from = $lang;
break;
}
}
// skip if no translation was updated
if (!isset($from)) {
return true;
}
foreach ($options['languages'] as $to) {
if ($to == $from) {
continue;
}
foreach ($invoker->Translation[$to] as $field => $value) {
if ($invoker->Translation->getTable()->isIdentifier($field)) {
continue;
}
$fromValue = $invoker->Translation[$from]->{$field};
if ($options['skipEmpty'] && !$fromValue) {
continue;
}
$translatedValue = $template->getTranslation($from, $to, $fromValue);
$invoker->Translation[$to]->{$field} = $translatedValue;
}
}
}
开发者ID:JoshuaEstes,项目名称:sfDoctrineExtraPlugin,代码行数:33,代码来源:GoogleI18n.php
示例11: preSave
/**
* preSave.
*
* @param Doctrine_Event $event
*/
public function preSave($event)
{
$record = $event->getInvoker();
if ($record->isNew()) {
$file = $record->getFilename();
if ($file != basename($file) && is_file($file)) {
$fs = new lyMediaFileSystem();
$dest_path = $record->getFolderPath();
$dest_file = $fs->generateUniqueFileName($dest_path, basename($file));
$fs->import($file, $dest_path . $dest_file);
$record->setType(mime_content_type($file));
$record->setFilename($dest_file);
}
if ($record->supportsThumbnails()) {
lyMediaTools::generateThumbnails($record->getFolderPath(), $record->getFilename());
}
} else {
$modified = $record->getModified(true);
if (isset($modified['folder_id']) || isset($modified['filename'])) {
//Selected new folder or edited filename: move/rename asset
$dest_folder = Doctrine::getTable('lyMediaFolder')->find($record->getFolderId());
$src_folder = $dest_folder;
if (isset($modified['folder_id'])) {
$src_folder = Doctrine::getTable('lyMediaFolder')->find($modified['folder_id']);
}
$src = $src_folder->getRelativePath() . (isset($modified['filename']) ? $modified['filename'] : $record->getFileName());
$dest = $dest_folder->getRelativePath() . $record->getFileName();
$fs = new lyMediaFileSystem();
$fs->rename($src, $dest, $record->supportsThumbnails());
}
}
}
开发者ID:pycmam,项目名称:lyMediaManagerPlugin,代码行数:37,代码来源:PluginlyMediaAsset.class.php
示例12: preUpdate
public function preUpdate(Doctrine_Event $event)
{
$record = $event->getInvoker();
if ($record->isModified()) {
$this->denormalize($record);
}
}
开发者ID:heristop,项目名称:SerializableDoctrineBehavior,代码行数:7,代码来源:Serializable.php
示例13: preSave
public function preSave(Doctrine_Event $event)
{
$invoker = $event->getInvoker();
$modified = $invoker->getModified();
if ($invoker->isNew()) {
// Check if the model is spam
$akismet = $this->getAkismet($invoker);
if ($akismet && (is_bool($akismet) || $akismet->isCommentSpam())) {
$invoker->is_not_spam = false;
$invoker->is_active = false;
} else {
$invoker->is_not_spam = true;
}
} else {
if (isset($modified['is_not_spam'])) {
$akismet = $this->getAkismet($invoker);
if ($akismet) {
if (!$invoker->is_not_spam) {
$akismet->submitSpam();
} else {
$akismet->submitHam();
}
}
}
}
}
开发者ID:jeremyfa,项目名称:dmAkismetPlugin,代码行数:26,代码来源:DmAkismet.php
示例14: postDelete
/**
* Deletes the object
*/
public function postDelete(Doctrine_Event $event)
{
try {
$this->deleteIndex($event->getInvoker());
} catch (sfException $e) {
// no context define, cannot do anything
}
}
开发者ID:palcoprincipal,项目名称:sfLucenePlugin,代码行数:11,代码来源:sfLuceneDoctrineListener.class.php
示例15: preSave
/**
* Set the geocodes automatically when a locatable object's locatable fields are modified
*
* @param Doctrine_Event $event
* @return void
* @author Brent Shaffer
*/
public function preSave(Doctrine_Event $event)
{
$object = $event->getInvoker();
$modified = array_keys($object->getModified());
if (array_intersect($this->_options['fields'], $modified)) {
$object->refreshGeocodes();
}
}
开发者ID:bshaffer,项目名称:Donate-Nashville,代码行数:15,代码来源:Locatable.php
示例16: preSave
/**
* Automatically calculates the accuracy of an address. The accuracy is not
* recalculated unless the address changes.
*/
public function preSave(Doctrine_Event $event)
{
$invoker = $event->getInvoker();
$accuracy = $this->_options['accuracy']['name'];
if ($invoker->{$accuracy} == Addressable::ACCURACY_PENDING || $invoker->isAddressModified()) {
$invoker->calculateAccuracy();
}
}
开发者ID:schmittjoh,项目名称:jmsDoctrinePlugin,代码行数:12,代码来源:Addressable.class.php
示例17: preInsert
public function preInsert(Doctrine_Event $event)
{
$name = $this->_options['name'];
$record = $event->getInvoker();
if (!$record->{$name}) {
$record->{$name} = $this->buildSlug($record);
}
}
开发者ID:kirvin,项目名称:the-nerdery,代码行数:8,代码来源:Sluggable.php
示例18: preUpdate
/**
* preUpdate
*
* @param object $Doctrine_Event
* @return void
*/
public function preUpdate(Doctrine_Event $event)
{
$updatedName = $this->_options['updated']['name'];
$modified = $event->getInvoker()->getModified();
if (!isset($modified[$updatedName])) {
$event->getInvoker()->{$updatedName} = self::getCurrentUserId();
}
}
开发者ID:jackbravo,项目名称:amaranto,代码行数:14,代码来源:Userstampable.php
示例19: postDelete
/**
* Prior to a record being deleted from the DB we delete it's config on disk. Note that the item's information is still in memory
* while the delete transaction and records are running.
* @param Doctrine_Event $event
*/
public function postDelete(Doctrine_Event $event)
{
$invoker =& $event->getInvoker();
$baseModel = Bluebox_Record::getBaseTransactionObject();
$identifier = $invoker->identifier();
// We do this because we can't set configs until we have saved all related models that may have an auto increment!
TelephonyListener::$changedModels[$invoker->getOid()] = array('action' => 'delete', 'record' => &$invoker, 'baseModel' => $baseModel, 'identifier' => $identifier);
}
开发者ID:swk,项目名称:bluebox,代码行数:13,代码来源:TelephonyRecordListener.php
示例20: postConnect
/**
* Post-connect listener. Will set charset and run init queries if configured.
*
* @param Doctrine_Event The Doctrine event object.
*
* @author David Zülke <[email protected]>
* @since 1.0.4
*/
public function postConnect(Doctrine_Event $event)
{
if ($this->database->hasParameter('charset')) {
$event->getInvoker()->setCharset($this->database->getParameter('charset'));
}
foreach ((array) $this->database->getParameter('init_queries') as $query) {
$event->getInvoker()->exec($query);
}
}
开发者ID:philippjenni,项目名称:icinga-web,代码行数:17,代码来源:AgaviDoctrineDatabaseEventListener.class.php
注:本文中的Doctrine_Event类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论