Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
e7135457
Commit
e7135457
authored
Dec 27, 2017
by
Guillaume Wauquier
Browse files
Merge branch '8-kml-refactoring' into ajout-des-dates-creation-modification
parents
d8f36648
71a8b6c6
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/lib/API/APIHelper.php
View file @
e7135457
...
...
@@ -31,6 +31,9 @@ abstract class APIHelper implements API
/** Override this const in children classes
* to the full-qualified model name. */
const
MODEL_NAME
=
null
;
/** Override this const in children classes to add a default sorting order.
* It is a string or an array passed to DAO->search. */
const
DEFAULT_ORDER
=
null
;
public
function
__construct
(
$dao
)
{
$this
->
dao
=
$dao
;
...
...
@@ -40,6 +43,14 @@ abstract class APIHelper implements API
return
new
static
(
$app
->
getDao
());
}
/** Use default order if no order is given. */
protected
function
getOrder
(
$order
)
{
if
(
$order
===
null
&&
static
::
DEFAULT_ORDER
!==
null
)
{
$order
=
static
::
DEFAULT_ORDER
;
}
return
$order
;
}
/** Get a single entry from it's ID. */
public
function
get
(
$id
)
{
return
$this
->
dao
->
read
(
static
::
MODEL_NAME
,
$id
);
...
...
@@ -48,6 +59,7 @@ abstract class APIHelper implements API
/** Get all entries.
* @param $order The order fields (see DAO->search) */
public
function
getAll
(
$order
=
null
)
{
$order
=
$this
->
getOrder
(
$order
);
return
$this
->
dao
->
search
(
static
::
MODEL_NAME
,
null
,
null
,
null
,
$order
);
}
...
...
@@ -57,6 +69,7 @@ abstract class APIHelper implements API
}
public
function
search
(
$conditions
,
$count
=
null
,
$offset
=
0
,
$order
=
null
)
{
$order
=
$this
->
getOrder
(
$order
);
return
$this
->
dao
->
search
(
static
::
MODEL_NAME
,
$conditions
,
$count
,
$offset
,
$order
);
}
...
...
src/lib/API/CategoryAPI.php
View file @
e7135457
...
...
@@ -28,6 +28,7 @@ use \Pasteque\Server\System\DAO\DAOCondition;
class
CategoryAPI
extends
APIRefHelper
{
const
MODEL_NAME
=
'Pasteque\Server\Model\Category'
;
const
DEFAULT_ORDER
=
[
'dispOrder'
,
'reference'
];
private
function
fillChildrenCategories
(
$cat
,
&
$result
)
{
$children
=
$this
->
dao
->
search
(
static
::
MODEL_NAME
,
...
...
src/lib/API/CustomerAPI.php
View file @
e7135457
...
...
@@ -26,6 +26,7 @@ namespace Pasteque\Server\API;
class
CustomerAPI
extends
APIHelper
implements
API
{
const
MODEL_NAME
=
'Pasteque\Server\Model\Customer'
;
const
DEFAULT_ORDER
=
'dispName'
;
public
function
getTopIds
(
$limit
=
10
)
{
// This is a report, but there are no reports.
...
...
src/lib/API/PaymentmodeAPI.php
View file @
e7135457
...
...
@@ -31,6 +31,7 @@ use \Pasteque\Server\System\DAO\DAOCondition;
class
PaymentmodeAPI
extends
APIHelper
{
const
MODEL_NAME
=
'Pasteque\Server\Model\PaymentMode'
;
const
DEFAULT_ORDER
=
'dispOrder'
;
// Same as APIHelper::write but delete return and values for replacement.
public
function
write
(
$data
)
{
...
...
src/lib/API/PlaceAPI.php
View file @
e7135457
...
...
@@ -29,6 +29,7 @@ use \Pasteque\Server\System\DAO\DAOCondition;
class
PlaceAPI
extends
APIHelper
{
const
MODEL_NAME
=
'Pasteque\Server\Model\Floor'
;
const
DEFAULT_ORDER
=
'dispOrder'
;
// Same as APIHelper::write but delete all places for replacement.
public
function
write
(
$data
)
{
...
...
src/lib/API/ProductAPI.php
View file @
e7135457
...
...
@@ -29,6 +29,8 @@ use \Pasteque\Server\System\DAO\DAOCondition;
class
ProductAPI
extends
APIRefHelper
{
const
MODEL_NAME
=
'Pasteque\Server\Model\Product'
;
const
DEFAULT_ORDER
=
[
'dispOrder'
,
'label'
];
private
static
$VISIBLE_CONDITION
=
null
;
private
static
$ARCHIVE_CONDITION
=
null
;
private
static
function
visibleCondition
()
{
...
...
@@ -46,14 +48,16 @@ class ProductAPI extends APIRefHelper
/** Get all Products currently in sold. */
public
function
getAll
(
$order
=
null
)
{
$order
=
$this
->
getOrder
(
$order
);
return
$this
->
dao
->
search
(
static
::
MODEL_NAME
,
static
::
visibleCondition
());
static
::
visibleCondition
()
,
null
,
null
,
$order
);
}
/** Get all Products currently not in sold. */
public
function
getArchive
()
{
$order
=
$this
->
getOrder
(
null
);
return
$this
->
dao
->
search
(
static
::
MODEL_NAME
,
static
::
archiveCondition
());
static
::
archiveCondition
()
,
null
,
null
,
$order
);
}
/** Get all products from a category, excluding archive.
...
...
@@ -61,17 +65,18 @@ class ProductAPI extends APIRefHelper
* Valid Id is an int or a numeric string.
* @throws \InvalidArgumentException If $category is not of valid type. */
public
function
getFromCategory
(
$category
)
{
$order
=
$this
->
getOrder
(
null
);
if
(
is_numeric
(
$category
))
{
$cat
=
$this
->
dao
->
read
(
Category
::
class
,
intval
(
$category
));
if
(
$cat
!=
null
)
{
return
$this
->
dao
->
search
(
static
::
MODEL_NAME
,
[
new
DAOCondition
(
'category'
,
'='
,
$cat
),
static
::
visibleCondition
()]);
static
::
visibleCondition
()]
,
null
,
null
,
$order
);
}
}
else
if
(
is_object
(
$category
)
&&
is_a
(
$category
,
Category
::
class
))
{
return
$this
->
dao
->
search
(
static
::
MODEL_NAME
,
[
new
DAOCondition
(
'category'
,
'='
,
$category
),
static
::
visibleCondition
()]);
static
::
visibleCondition
()]
,
null
,
null
,
$order
);
}
else
{
throw
new
\
InvalidArgumentException
(
'Incompatible category type'
);
}
...
...
src/lib/API/RoleAPI.php
View file @
e7135457
...
...
@@ -26,4 +26,5 @@ namespace Pasteque\Server\API;
class
RoleAPI
extends
APIHelper
implements
API
{
const
MODEL_NAME
=
'Pasteque\Server\Model\Role'
;
const
DEFAULT_ORDER
=
'name'
;
}
\ No newline at end of file
src/lib/API/TariffareaAPI.php
View file @
e7135457
...
...
@@ -30,6 +30,7 @@ use \Pasteque\Server\System\DAO\DAOCondition;
class
TariffareaAPI
extends
APIHelper
{
const
MODEL_NAME
=
'Pasteque\Server\Model\TariffArea'
;
const
DEFAULT_ORDER
=
'dispOrder'
;
// Same as APIHelper::write but delete all price for replacement.
public
function
write
(
$data
)
{
...
...
src/lib/API/TaxAPI.php
View file @
e7135457
...
...
@@ -26,4 +26,5 @@ namespace Pasteque\Server\API;
class
TaxAPI
extends
APIHelper
implements
API
{
const
MODEL_NAME
=
'Pasteque\Server\Model\Tax'
;
const
DEFAULT_ORDER
=
'-rate'
;
}
\ No newline at end of file
src/lib/API/TicketAPI.php
View file @
e7135457
...
...
@@ -32,6 +32,7 @@ use \Pasteque\Server\System\DAO\DAOCondition;
class
TicketAPI
extends
APIHelper
implements
API
{
const
MODEL_NAME
=
'Pasteque\Server\Model\Ticket'
;
const
DEFAULT_ORDER
=
'-number'
;
/** Check for duplicated ticket in database. This is required because
* Doctrine will crash everything if a DB exception is thrown. */
...
...
src/lib/API/UserAPI.php
View file @
e7135457
...
...
@@ -29,9 +29,7 @@ use \Pasteque\Server\System\DAO\DAOCondition;
class
UserAPI
extends
APIHelper
implements
API
{
const
MODEL_NAME
=
'Pasteque\Server\Model\User'
;
const
DEFAULT_ORDER
=
'name'
;
public
function
getByName
(
$name
)
{
...
...
src/lib/Model/CompositionGroup.php
View file @
e7135457
...
...
@@ -107,7 +107,8 @@ class CompositionGroup extends DoctrineModel
public
function
setImage
(
$image
)
{
$this
->
image
=
$image
;
}
/**
* @OneToMany(targetEntity="\Pasteque\Server\Model\CompositionProduct", mappedBy="compositionGroup", cascade={"persist"}, orphanRemoval=true) */
* @OneToMany(targetEntity="\Pasteque\Server\Model\CompositionProduct", mappedBy="compositionGroup", cascade={"persist"}, orphanRemoval=true)
* @OrderBy({"dispOrder" = "ASC"}) */
protected
$compositionProducts
;
public
function
getCompositionProducts
()
{
return
$this
->
compositionProducts
;
}
public
function
setCompositionProducts
(
$compositionProducts
)
{
...
...
src/lib/Model/Product.php
View file @
e7135457
...
...
@@ -279,7 +279,8 @@ class Product extends DoctrineModel
public
function
setComposition
(
$composition
)
{
$this
->
composition
=
$composition
;
}
/**
* @OneToMany(targetEntity="\Pasteque\Server\Model\CompositionGroup", mappedBy="product", cascade={"persist"}, orphanRemoval=true) */
* @OneToMany(targetEntity="\Pasteque\Server\Model\CompositionGroup", mappedBy="product", cascade={"persist"}, orphanRemoval=true)
* @OrderBy({"dispOrder" = "ASC"}) */
protected
$compositionGroups
;
public
function
getcompositionGroups
()
{
return
$this
->
compositionGroups
;
}
public
function
setCompositionGroups
(
$compositionGroups
)
{
...
...
Write
Preview
Supports
Markdown
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