Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
6d83243b
Commit
6d83243b
authored
Feb 29, 2016
by
Vassilis Kanellopoulos
Browse files
sync with sch inventory on first login if no labs or assets for school
parent
c0671634
Changes
3
Hide whitespace changes
Inline
Side-by-side
module/sch_inventory/src/Equipment.php
deleted
100644 → 0
View file @
c0671634
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
SchInventory
;
class
Equipment
{
protected
$id
;
protected
$category
;
protected
$description
;
protected
$location
;
protected
$manufacturer
;
protected
$propertyNumber
;
public
function
__construct
(
$id
,
$category
,
$description
,
$location
,
$manufacturer
,
$propertyNumber
)
{
$this
->
id
=
$id
;
$this
->
category
=
$category
;
$this
->
description
=
$description
;
$this
->
location
=
$location
;
$this
->
manufacturer
=
$manufacturer
;
$this
->
propertyNumber
=
$propertyNumber
;
}
public
function
__get
(
$name
)
{
if
(
property_exists
(
$this
,
$name
))
{
return
$this
->
{
$name
};
}
return
;
}
public
function
toArray
()
{
return
[
'id'
=>
$this
->
id
,
'category'
=>
$this
->
category
,
'description'
=>
$this
->
description
,
'location'
=>
$this
->
location
,
'manufacturer'
=>
$this
->
manufacturer
,
'propertyNumber'
=>
$this
->
propertyNumber
,
];
}
}
module/sch_inventory/src/EquipmentCollection.php
deleted
100644 → 0
View file @
c0671634
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
SchInventory
;
use
CallbackFilterIterator
;
use
InvalidArgumentException
;
use
Traversable
;
class
EquipmentCollection
extends
ImmutableArrayObject
{
/**
* Collection constructor
*
* @param array|Traversable
*/
public
function
__construct
(
$equipmentObjects
)
{
if
(
$equipmentObjects
instanceof
Traversable
)
{
$equipmentObjects
=
iterator_to_array
(
$equipmentObjects
);
}
$previousHandler
=
set_error_handler
([
'self'
,
'handleErrors'
]);
parent
::
__construct
(
array_map
(
function
(
Equipment
$equipment
)
{
return
$equipment
;
},
$equipmentObjects
));
set_error_handler
(
$previousHandler
);
}
/**
* Returns a new Equipment collection with equimpment matching the given location
*
* @param string $location
* @retun EquipmentCollection
*/
public
function
withLocation
(
$location
)
{
return
new
self
(
new
CallbackFilterIterator
(
$this
->
getIterator
(),
function
(
Equipment
$equipment
)
use
(
$location
)
{
return
$equipment
->
location
===
$location
;
}));
}
/**
* Returns a new Equipment collection with equimpment matching the given category
*
* @param string $category
* @retun EquipmentCollection
*/
public
function
withCategory
(
$category
)
{
return
new
self
(
new
CallbackFilterIterator
(
$this
->
getIterator
(),
function
(
Equipment
$equipment
)
use
(
$category
)
{
return
$equipment
->
category
===
$category
;
}));
}
private
static
function
handleErrors
(
$severity
,
$message
,
$file
,
$line
)
{
throw
new
InvalidArgumentException
(
$message
);
}
}
module/sch_inventory/src/ImmutableArrayObject.php
deleted
100644 → 0
View file @
c0671634
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
SchInventory
;
use
ArrayObject
;
use
LogicException
;
class
ImmutableArrayObject
extends
ArrayObject
{
public
function
append
(
$value
)
{
throw
new
LogicException
(
'Attempting to write to an immutable array'
);
}
public
function
exchangeArray
(
$input
)
{
throw
new
LogicException
(
'Attempting to write to an immutable array'
);
}
public
function
offsetSet
(
$index
,
$newval
)
{
throw
new
LogicException
(
'Attempting to write to an immutable array'
);
}
public
function
offsetUnset
(
$index
)
{
throw
new
LogicException
(
'Attempting to write to an immutable array'
);
}
}
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