Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
fa5c28fd
Commit
fa5c28fd
authored
Oct 13, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated plugin classes to use the refactored main class
parent
a9e5a359
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
46 deletions
+35
-46
AuditLog.php
lib/Doctrine/AuditLog.php
+5
-0
Plugin.php
lib/Doctrine/Plugin.php
+1
-1
Search.php
lib/Doctrine/Search.php
+15
-29
Searchable.php
lib/Doctrine/Template/Searchable.php
+14
-16
No files found.
lib/Doctrine/AuditLog.php
View file @
fa5c28fd
...
...
@@ -96,6 +96,11 @@ class Doctrine_AuditLog extends Doctrine_Plugin
$id
=
$table
->
getIdentifier
();
$options
=
array
(
'className'
=>
$className
);
$relations
=
array
(
$name
=>
array
(
'local'
=>
$local
,
'foreign'
=>
$id
,
'onDelete'
=>
'CASCADE'
,
'onUpdate'
=>
'CASCADE'
));
$this
->
generateClass
(
$options
,
$columns
,
array
());
...
...
lib/Doctrine/Plugin.php
View file @
fa5c28fd
...
...
@@ -118,7 +118,7 @@ class Doctrine_Plugin
unset
(
$def
[
'sequence'
]);
unset
(
$def
[
'primary'
]);
$col
=
strtolower
(
Doctrine
::
tableize
(
$table
->
getComponentName
())
.
'_'
.
$column
)
;
$col
=
$column
;
$def
[
'primary'
]
=
true
;
$fk
[
$col
]
=
$def
;
...
...
lib/Doctrine/Search.php
View file @
fa5c28fd
...
...
@@ -68,13 +68,21 @@ class Doctrine_Search extends Doctrine_Plugin
$name
=
$record
->
getTable
()
->
getComponentName
();
if
(
$this
->
_options
[
'batchUpdates'
]
===
true
)
{
$conn
->
insert
(
Doctrine
::
tableize
(
$class
),
array
(
'foreign_id'
=>
$id
));
$conn
=
$record
->
getTable
()
->
getConnection
();
$index
=
new
$class
();
foreach
(
$record
->
identifier
()
as
$id
=>
$value
)
{
$index
->
$id
=
$value
;
}
$index
->
save
();
}
else
{
foreach
(
$fields
as
$field
)
{
$data
=
$record
->
get
(
$field
);
$terms
=
$this
->
analyze
(
$data
);
foreach
(
$terms
as
$pos
=>
$term
)
{
$index
=
new
$class
();
...
...
@@ -82,7 +90,7 @@ class Doctrine_Search extends Doctrine_Plugin
$index
->
position
=
$pos
;
$index
->
field
=
$field
;
$index
->
$name
=
$record
;
$index
->
save
();
}
}
...
...
@@ -144,12 +152,10 @@ class Doctrine_Search extends Doctrine_Plugin
$columns
=
array
(
'keyword'
=>
array
(
'type'
=>
'string'
,
'length'
=>
200
,
'notnull'
=>
true
,
'primary'
=>
true
,
),
'field'
=>
array
(
'type'
=>
'string'
,
'length'
=>
50
,
'notnull'
=>
true
,
'primary'
=>
true
),
'position'
=>
array
(
'type'
=>
'integer'
,
'length'
=>
8
,
...
...
@@ -159,34 +165,14 @@ class Doctrine_Search extends Doctrine_Plugin
$id
=
$table
->
getIdentifier
();
$options
=
array
(
'className'
=>
$className
);
$fk
=
array
();
foreach
((
array
)
$id
as
$column
)
{
$def
=
$table
->
getDefinitionOf
(
$column
);
unset
(
$def
[
'autoincrement'
]);
unset
(
$def
[
'sequence'
]);
unset
(
$def
[
'primary'
]);
$col
=
strtolower
(
Doctrine
::
tableize
(
$name
)
.
'_'
.
$column
);
$def
[
'primary'
]
=
true
;
$fk
[
$col
]
=
$def
;
}
$local
=
(
count
(
$fk
)
>
1
)
?
array_keys
(
$fk
)
:
key
(
$fk
);
$relations
=
array
(
$name
=>
array
(
'local'
=>
$local
,
'foreign'
=>
$id
,
'onDelete'
=>
'CASCADE'
,
'onUpdate'
=>
'CASCADE'
));
$fk
=
$this
->
generateForeignKeys
(
$table
);
$columns
+=
$fk
;
$relations
=
$this
->
generateRelation
(
$table
,
$fk
);
$columns
+=
$fk
;
$this
->
generateClass
(
$options
,
$columns
,
$relations
);
$this
->
_options
[
'pluginTable'
]
=
$table
->
getConnection
()
->
getTable
(
$this
->
_options
[
'className'
]);
return
true
;
...
...
lib/Doctrine/Template/Searchable.php
View file @
fa5c28fd
...
...
@@ -32,32 +32,30 @@
*/
class
Doctrine_Template_Searchable
extends
Doctrine_Template
{
protected
$_search
;
public
function
__construct
(
array
$options
)
{
$this
->
_search
=
new
Doctrine_Search
(
$options
);
$this
->
_plugin
=
new
Doctrine_Search
(
$options
);
}
public
function
getPlugin
()
{
return
$this
->
_plugin
;
}
public
function
setUp
()
{
$id
=
$this
->
_table
->
getIdentifier
();
$name
=
$this
->
_table
->
getComponentName
();
$className
=
$this
->
_
search
->
getOption
(
'className'
);
$className
=
$this
->
_
plugin
->
getOption
(
'className'
);
if
(
strpos
(
$className
,
'%CLASS%'
)
!==
false
)
{
$this
->
_
search
->
setOption
(
'className'
,
str_replace
(
'%CLASS%'
,
$name
,
$className
));
$className
=
$this
->
_
search
->
getOption
(
'className'
);
$this
->
_
plugin
->
setOption
(
'className'
,
str_replace
(
'%CLASS%'
,
$name
,
$className
));
$className
=
$this
->
_
plugin
->
getOption
(
'className'
);
}
$this
->
_search
->
buildDefinition
(
$this
->
_table
);
foreach
((
array
)
$id
as
$column
)
{
$foreign
[]
=
strtolower
(
Doctrine
::
tableize
(
$this
->
_table
->
getComponentName
())
.
'_'
.
$column
);
}
$foreign
=
(
count
(
$foreign
)
>
1
)
?
$foreign
:
current
(
$foreign
);
$this
->
_plugin
->
buildDefinition
(
$this
->
_table
);
$this
->
hasMany
(
$className
,
array
(
'local'
=>
$id
,
'foreign'
=>
$
foreign
));
$this
->
hasMany
(
$className
,
array
(
'local'
=>
$id
,
'foreign'
=>
$
id
));
$this
->
addListener
(
new
Doctrine_Search_Listener
(
$this
->
_
search
));
$this
->
addListener
(
new
Doctrine_Search_Listener
(
$this
->
_
plugin
));
}
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment