mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
Fix php style
This commit is contained in:
parent
461bd9c98d
commit
b8bd067dc7
59 changed files with 2307 additions and 1868 deletions
|
@ -13,26 +13,18 @@ namespace controllers\internals;
|
|||
|
||||
class Media extends StandardController
|
||||
{
|
||||
protected $model = null;
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Get the model for the Controller
|
||||
* @return \descartes\Model
|
||||
*/
|
||||
protected function get_model () : \descartes\Model
|
||||
{
|
||||
$this->model = $this->model ?? new \models\Media($this->bdd);
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a media
|
||||
* @param int $id_user : Id of the user
|
||||
* @param int $id_scheduled : Id of the scheduled
|
||||
* @param array $media : $_FILES media array
|
||||
* Create a media.
|
||||
*
|
||||
* @param int $id_user : Id of the user
|
||||
* @param int $id_scheduled : Id of the scheduled
|
||||
* @param array $media : $_FILES media array
|
||||
*
|
||||
* @return bool : false on error, new media id else
|
||||
*/
|
||||
public function create (int $id_user, int $id_scheduled, array $media) : bool
|
||||
public function create(int $id_user, int $id_scheduled, array $media): bool
|
||||
{
|
||||
$internal_scheduled = new Scheduled($this->bdd);
|
||||
$scheduled = $internal_scheduled->get_for_user($id_user, $id_scheduled);
|
||||
|
@ -40,14 +32,14 @@ namespace controllers\internals;
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$result_upload_media = \controllers\internals\Tool::upload_file($media);
|
||||
if ($result_upload_media['success'] == false)
|
||||
if (false === $result_upload_media['success'])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$datas = [
|
||||
$datas = [
|
||||
'id_scheduled' => $id_scheduled,
|
||||
'path' => $result_upload_media['content'],
|
||||
];
|
||||
|
@ -55,22 +47,23 @@ namespace controllers\internals;
|
|||
return (bool) $this->get_model()->insert($datas);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update a media for a user
|
||||
* @param int $id_user : user id
|
||||
* @param int $id_media : Media id
|
||||
* @param int $id_scheduled : Id of the scheduled
|
||||
* @param string $path : Path of the file
|
||||
* Update a media for a user.
|
||||
*
|
||||
* @param int $id_user : user id
|
||||
* @param int $id_media : Media id
|
||||
* @param int $id_scheduled : Id of the scheduled
|
||||
* @param string $path : Path of the file
|
||||
*
|
||||
* @return bool : false on error, true on success
|
||||
*/
|
||||
public function update_for_user (int $id_user, int $id_media, int $id_scheduled, string $path) : bool
|
||||
public function update_for_user(int $id_user, int $id_media, int $id_scheduled, string $path): bool
|
||||
{
|
||||
$media = [
|
||||
$media = [
|
||||
'id_scheduled' => $id_scheduled,
|
||||
'path' => $path,
|
||||
];
|
||||
|
||||
|
||||
$internal_scheduled = new Scheduled($this->bdd);
|
||||
$scheduled = $this->get_for_user($id_user, $id_scheduled);
|
||||
if (!$scheduled)
|
||||
|
@ -80,15 +73,16 @@ namespace controllers\internals;
|
|||
|
||||
return (bool) $this->get_model()->update_for_user($id_user, $id_media, $media);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete a media for a user
|
||||
* Delete a media for a user.
|
||||
*
|
||||
* @param int $id_user : User id
|
||||
* @param int $id : Entry id
|
||||
* @param int $id : Entry id
|
||||
*
|
||||
* @return int : Number of removed rows
|
||||
*/
|
||||
public function delete_for_user (int $id_user, int $id_media) : bool
|
||||
public function delete_for_user(int $id_user, int $id_media): bool
|
||||
{
|
||||
$media = $this->get_model()->get_for_user($id_user, $id_media);
|
||||
if (!$media)
|
||||
|
@ -100,15 +94,16 @@ namespace controllers\internals;
|
|||
|
||||
return $this->get_model()->delete_for_user($id_user, $id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Delete a media for a scheduled and a user
|
||||
* @param int $id_user : User id
|
||||
* Delete a media for a scheduled and a user.
|
||||
*
|
||||
* @param int $id_user : User id
|
||||
* @param int $id_scheduled : Scheduled id to delete medias for
|
||||
*
|
||||
* @return int : Number of removed rows
|
||||
*/
|
||||
public function delete_for_scheduled_and_user (int $id_user, int $id_scheduled) : bool
|
||||
public function delete_for_scheduled_and_user(int $id_user, int $id_scheduled): bool
|
||||
{
|
||||
$media = $this->get_model()->get_for_scheduled_and_user($id_user, $id_scheduled);
|
||||
if ($media)
|
||||
|
@ -119,15 +114,28 @@ namespace controllers\internals;
|
|||
return $this->get_model()->delete_for_scheduled_and_user($id_user, $id_scheduled);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find medias for a scheduled and a user
|
||||
* @param int $id_user : User id
|
||||
* Find medias for a scheduled and a user.
|
||||
*
|
||||
* @param int $id_user : User id
|
||||
* @param int $id_scheduled : Scheduled id to delete medias for
|
||||
*
|
||||
* @return mixed : Medias || false
|
||||
*/
|
||||
public function get_for_scheduled_and_user (int $id_user, int $id_scheduled)
|
||||
public function get_for_scheduled_and_user(int $id_user, int $id_scheduled)
|
||||
{
|
||||
return $this->get_model()->get_for_scheduled_and_user($id_user, $id_scheduled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model for the Controller.
|
||||
*
|
||||
* @return \descartes\Model
|
||||
*/
|
||||
protected function get_model(): \descartes\Model
|
||||
{
|
||||
$this->model = $this->model ?? new \models\Media($this->bdd);
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue