Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
LeanMapper Workflow
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Mpro
LeanMapper Workflow
Commits
36857561
Commit
36857561
authored
Jun 04, 2014
by
Tomas Lang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Entity: alternative for magic functions like addTo* - call addTo(*)
parent
da625a73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
Entity.php
src/LeanMapperWorkflow/Entity.php
+13
-1
No files found.
src/LeanMapperWorkflow/Entity.php
View file @
36857561
...
...
@@ -5,6 +5,9 @@ namespace LeanMapperWorkflow;
use
LeanMapper\Relationship\HasMany
;
use
LeanMapper\Filtering
;
use
LeanMapper\Fluent
;
use
InvalidArgumentException
;
use
Nette\Callback
;
use
Nette\Utils\Strings
;
abstract
class
Entity
extends
\LeanMapper\Entity
...
...
@@ -13,10 +16,19 @@ abstract class Entity extends \LeanMapper\Entity
/**
* @param string $name
* @param array $arguments
*
* @throws InvalidArgumentException
*/
public
function
__call
(
$name
,
array
$arguments
)
{
if
(
substr
(
$name
,
0
,
10
)
===
'getCountOf'
)
if
(
in_array
(
$name
,
[
'addTo'
,
'removeFrom'
,
'removeAll'
,
'replaceAll'
,
'getCountOf'
]))
{
if
(
count
(
$arguments
)
===
0
)
{
throw
new
InvalidArgumentException
(
"Method '
$name
' in entity "
.
get_called_class
()
.
" expects at least one argument with target column name."
);
}
return
$this
->
__call
(
$name
.
Strings
::
firstUpper
(
array_shift
(
$arguments
)),
$arguments
);
}
elseif
(
substr
(
$name
,
0
,
10
)
===
'getCountOf'
)
{
$property
=
$this
->
getCurrentReflection
()
->
getEntityProperty
(
lcfirst
(
substr
(
$name
,
10
)));
...
...
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