Complex classes like FlexiBeeRO often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FlexiBeeRO, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 17 | class FlexiBeeRO extends \Ease\Sand { |
||
| 18 | |||
| 19 | use \Ease\RecordKey; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Where to get JSON files with evidence stricture etc. |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | public static $infoDir = __DIR__ . '/../../static'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Version of FlexiPeeHP library |
||
| 29 | * |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | public static $libVersion = '1.37'; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Basic namespace for communication with FlexiBee |
||
| 36 | * |
||
| 37 | * @var string Jmený prostor datového bloku odpovědi |
||
| 38 | */ |
||
| 39 | public $nameSpace = 'winstrom'; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * URL of object data in FlexiBee |
||
| 43 | * @var string url |
||
| 44 | */ |
||
| 45 | public $apiURL = null; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Data block in response field. |
||
| 49 | * |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | public $resultField = 'results'; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Communication protocol version used. |
||
| 56 | * |
||
| 57 | * @var string Verze použitého API |
||
| 58 | */ |
||
| 59 | public $protoVersion = '1.0'; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Evidence used by object |
||
| 63 | * |
||
| 64 | * @link https://demo.flexibee.eu/c/demo/evidence-list Přehled evidencí |
||
| 65 | * |
||
| 66 | * @var string |
||
| 67 | */ |
||
| 68 | public $evidence = null; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Detaily evidence užité objektem |
||
| 72 | * |
||
| 73 | * @var array |
||
| 74 | */ |
||
| 75 | public $evidenceInfo = []; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Default communication format. |
||
| 79 | * |
||
| 80 | * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů |
||
| 81 | * |
||
| 82 | * @var string json|xml|... |
||
| 83 | */ |
||
| 84 | public $format = 'json'; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * requested response format |
||
| 88 | * |
||
| 89 | * @link https://www.flexibee.eu/api/dokumentace/ref/format-types Přehled možných formátů |
||
| 90 | * |
||
| 91 | * @var string json|xml|... |
||
| 92 | */ |
||
| 93 | public $responseFormat = 'json'; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Curl Handle. |
||
| 97 | * |
||
| 98 | * @var resource |
||
| 99 | */ |
||
| 100 | public $curl = null; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @link https://demo.flexibee.eu/devdoc/company-identifier Identifikátor firmy |
||
| 104 | * @var string |
||
| 105 | */ |
||
| 106 | public $company = null; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * [protocol://]Server[:port] |
||
| 110 | * @var string |
||
| 111 | */ |
||
| 112 | public $url = null; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * REST API Username |
||
| 116 | * @var string |
||
| 117 | */ |
||
| 118 | public $user = null; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * REST API Password |
||
| 122 | * @var string |
||
| 123 | */ |
||
| 124 | public $password = null; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * @var array Pole HTTP hlaviček odesílaných s každým požadavkem |
||
| 128 | */ |
||
| 129 | public $defaultHttpHeaders = []; |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Default additional request url parameters after question mark |
||
| 133 | * |
||
| 134 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls Common params |
||
| 135 | * @link https://www.flexibee.eu/api/dokumentace/ref/paging Paging params |
||
| 136 | * @var array |
||
| 137 | */ |
||
| 138 | public $defaultUrlParams = []; |
||
| 139 | |||
| 140 | /** |
||
| 141 | * Identifikační řetězec. |
||
| 142 | * |
||
| 143 | * @var string |
||
| 144 | */ |
||
| 145 | public $init = null; |
||
| 146 | |||
| 147 | /** |
||
| 148 | * Sloupeček s názvem. |
||
| 149 | * |
||
| 150 | * @var string |
||
| 151 | */ |
||
| 152 | public $nameColumn = 'nazev'; |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Sloupeček obsahující datum vložení záznamu do shopu. |
||
| 156 | * |
||
| 157 | * @var string |
||
| 158 | */ |
||
| 159 | public $myCreateColumn = 'false'; |
||
| 160 | |||
| 161 | /** |
||
| 162 | * Slopecek obsahujici datum poslení modifikace záznamu do shopu. |
||
| 163 | * |
||
| 164 | * @var string |
||
| 165 | */ |
||
| 166 | public $myLastModifiedColumn = 'lastUpdate'; |
||
| 167 | |||
| 168 | /** |
||
| 169 | * Klíčový idendifikátor záznamu. |
||
| 170 | * |
||
| 171 | * @var string |
||
| 172 | */ |
||
| 173 | public $fbKeyColumn = 'id'; |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Informace o posledním HTTP requestu. |
||
| 177 | * |
||
| 178 | * @var * |
||
| 179 | */ |
||
| 180 | public $curlInfo; |
||
| 181 | |||
| 182 | /** |
||
| 183 | * Informace o poslední HTTP chybě. |
||
| 184 | * |
||
| 185 | * @var string |
||
| 186 | */ |
||
| 187 | public $lastCurlError = null; |
||
| 188 | |||
| 189 | /** |
||
| 190 | * Used codes storage. |
||
| 191 | * |
||
| 192 | * @var array |
||
| 193 | */ |
||
| 194 | public $codes = null; |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Last Inserted ID. |
||
| 198 | * |
||
| 199 | * @var int |
||
| 200 | */ |
||
| 201 | public $lastInsertedID = null; |
||
| 202 | |||
| 203 | /** |
||
| 204 | * Default Line Prefix. |
||
| 205 | * |
||
| 206 | * @var string |
||
| 207 | */ |
||
| 208 | public $prefix = '/c/'; |
||
| 209 | |||
| 210 | /** |
||
| 211 | * Raw Content of last curl response |
||
| 212 | * |
||
| 213 | * @var string |
||
| 214 | */ |
||
| 215 | public $lastCurlResponse; |
||
| 216 | |||
| 217 | /** |
||
| 218 | * HTTP Response code of last request |
||
| 219 | * |
||
| 220 | * @var int |
||
| 221 | */ |
||
| 222 | public $lastResponseCode = null; |
||
| 223 | |||
| 224 | /** |
||
| 225 | * Body data for next curl POST operation |
||
| 226 | * |
||
| 227 | * @var string |
||
| 228 | */ |
||
| 229 | public $postFields = null; |
||
| 230 | |||
| 231 | /** |
||
| 232 | * Last operation result data or message(s) |
||
| 233 | * |
||
| 234 | * @var array |
||
| 235 | */ |
||
| 236 | public $lastResult = null; |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Number from @rowCount in response |
||
| 240 | * @var int |
||
| 241 | */ |
||
| 242 | public $rowCount = null; |
||
| 243 | |||
| 244 | /** |
||
| 245 | * Number from @globalVersion |
||
| 246 | * @var int |
||
| 247 | */ |
||
| 248 | public $globalVersion = null; |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @link https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
| 252 | * @var string filter query |
||
| 253 | */ |
||
| 254 | public $filter; |
||
| 255 | |||
| 256 | /** |
||
| 257 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
| 258 | * @var string |
||
| 259 | */ |
||
| 260 | protected $action; |
||
| 261 | |||
| 262 | /** |
||
| 263 | * Pole akcí které podporuje ta která evidence |
||
| 264 | * @link https://demo.flexibee.eu/c/demo/faktura-vydana/actions.json Např. Akce faktury |
||
| 265 | * @var array |
||
| 266 | */ |
||
| 267 | public $actionsAvailable = null; |
||
| 268 | |||
| 269 | /** |
||
| 270 | * Parmetry pro URL |
||
| 271 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Všechny podporované parametry |
||
| 272 | * @var array |
||
| 273 | */ |
||
| 274 | public $urlParams = [ |
||
| 275 | 'add-global-version' => ['type' => 'boolean', 'description' => 'The response will contain the global version number of the current export'], |
||
| 276 | 'add-row-count' => ['type' => 'boolean', 'description' => 'Adding Total Records to Output (Pagination)'], |
||
| 277 | 'as-gui' => ['type' => 'boolean', 'description' => 'Turns on functions that complement the GUI processing outputs'], |
||
| 278 | 'auth' => ['type' => 'string', 'description' => 'http: Forces login using HTTP authentication, for example, to change the default WUI login method. html: Force HTML form authentication. This can be useful to suppress automatic SSO authentication.'], |
||
| 279 | 'authSessionId' => ['type' => 'string', 'description' => 'Authentification Session ID'], |
||
| 280 | 'code-as-id' => ['type' => 'boolean', 'description' => 'If an object has unique code, it is also exported (except for the <code> element) as <id> code: ... </id>'], |
||
| 281 | 'code-in-response' => ['type' => 'boolean', 'description' => 'The response will contain not only ID and URL for each object, but also code.'], |
||
| 282 | 'delimeter' => ['type' => 'string', 'description' => 'Specifies the input / output file separator in CSV format.', |
||
| 283 | 'example' => ';'], |
||
| 284 | 'detail' => ['type' => 'string', 'description' => 'Definition of the level of detail'], //See: https://www.flexibee.eu/api/dokumentace/ref/detail-levels |
||
| 285 | 'dir' => ['type' => 'string', 'description' => 'Sorting direction.', 'example' => 'desc'], |
||
| 286 | 'dry-run' => ['type' => 'boolean', 'description' => 'Test run (dry-run)'], // See: https://www.flexibee.eu/api/dokumentace/ref/dry-run/ |
||
| 287 | 'encoding' => ['type' => 'string', 'description' => 'Specifies the encoding of the input / output file in CSV format.'], |
||
| 288 | 'export-settings' => ['type' => 'boolean', 'description' => 'Export one extra entry with current settings at the beginning'], |
||
| 289 | 'fail-on-warning' => ['type' => 'boolean', 'description' => 'If a warning occurs, do not save a record (Data Validation)'], |
||
| 290 | 'filter' => ['type' => 'string', 'description' => 'filter results by this param'], |
||
| 291 | 'format' => ['type' => 'string', 'description' => 'One of the compiled XSL transforms will be applied to the output XML.'], |
||
| 292 | 'idUcetniObdobi' => ['type' => 'string', 'description' => ''], //See: https://www.flexibee.eu/api/dokumentace/ref/stavy-uctu/ |
||
| 293 | 'includes' => ['type' => 'string', 'description' => 'Include related detail level object ', |
||
| 294 | 'example' => 'faktura-vydana/stredisko'], |
||
| 295 | 'inDesktopApp' => ['type' => 'boolean', 'description' => 'Hide menu and navigation in html format'], // Note: Undocumented function (html only) |
||
| 296 | 'limit' => ['type' => 'integer', 'description' => 'number of requested results'], |
||
| 297 | 'mode' => ['type' => 'string', 'description' => 'Support for RubyOnRails', |
||
| 298 | 'example' => 'ruby'], |
||
| 299 | 'no-ext-ids' => ['type' => 'boolean', 'description' => 'The answer will not contain external identifiers (performance optimization)'], |
||
| 300 | 'no-http-errors' => ['type' => 'boolean', 'description' => 'If a 4xx error occurs while processing a request, the server sends 200 OK anyway'], |
||
| 301 | 'no-ids' => ['type' => 'boolean', 'description' => 'The response will not contain any primary identifiers (performance optimization). It only affects the main records.'], |
||
| 302 | 'only-ext-ids' => ['type' => 'boolean', 'description' => 'The primary key will not be exported, the <id> elements will only contain the external ID. Similar no-ids, but also affects subevidencies.'], |
||
| 303 | 'order' => ['type' => 'string', 'description' => 'Sorting records', 'example' => 'nazev@A'], |
||
| 304 | 'relations' => ['type' => 'string', 'description' => 'Adding session data (see detail levels) A session overview can be obtained for each record (/ relations).'], |
||
| 305 | 'report-lang' => ['type' => 'string', 'description' => 'The language in which to print the output when exporting to PDF', |
||
| 306 | 'example' => 'en'], |
||
| 307 | 'report-name' => ['type' => 'string', 'description' => 'The name of the printout when exporting to PDF', |
||
| 308 | 'example' => 'invoice'], |
||
| 309 | 'report-sign' => ['type' => 'string', 'description' => 'Whether the PDF should be exported electronically signed'], |
||
| 310 | 'skupina-stitku' => ['type' => 'string', 'description' => 'Enables grouping of labels when exporting by group (multiple labels)'], |
||
| 311 | 'sort' => ['type' => 'string', 'description' => 'Sorting records for ExtJS'], |
||
| 312 | 'start' => ['type' => 'integer', 'description' => 'Pagination'], |
||
| 313 | 'stitky-as-ids' => ['type' => 'boolean', 'description' => 'Labels will be exported and imported not as a code list but as a list of numeric IDs'], |
||
| 314 | 'use-ext-id' => ['type' => 'boolean', 'description' => 'If the object contains an external ESHOP or MY ID, use it as a bind.'], |
||
| 315 | 'use-internal-id' => ['type' => 'boolean', 'description' => 'In addition to the ref and showAs for objects, it also supplies an internalId attribute that contains the internal record ID'], |
||
| 316 | 'xpath' => ['type' => 'string', 'description' => 'Apply XPATH to result', |
||
| 317 | 'example' => '//winstrom/adresar/email/text()'] // See: https://www.flexibee.eu/api/dokumentace/ref/xpath/ |
||
| 318 | ]; |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Session ID |
||
| 322 | * @var string |
||
| 323 | */ |
||
| 324 | public $authSessionId = null; |
||
| 325 | |||
| 326 | /** |
||
| 327 | * Token obtained during login procedure |
||
| 328 | * @var string |
||
| 329 | */ |
||
| 330 | public $refreshToken = null; |
||
| 331 | |||
| 332 | /** |
||
| 333 | * Save 404 results to log ? |
||
| 334 | * @var boolean |
||
| 335 | */ |
||
| 336 | protected $ignoreNotFound = false; |
||
| 337 | |||
| 338 | /** |
||
| 339 | * Array of errors caused by last request |
||
| 340 | * @var array |
||
| 341 | */ |
||
| 342 | protected $errors = []; |
||
| 343 | |||
| 344 | /** |
||
| 345 | * List of Error500 reports sent |
||
| 346 | * @var array |
||
| 347 | */ |
||
| 348 | private $reports = []; |
||
| 349 | |||
| 350 | /** |
||
| 351 | * Send Error500 Report to |
||
| 352 | * @var string email address |
||
| 353 | */ |
||
| 354 | public $reportRecipient = '[email protected]'; |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Formating string for \DateTime::format() for datetime columns |
||
| 358 | * @var string |
||
| 359 | */ |
||
| 360 | static public $DateTimeFormat = 'Y-m-d\TH:i:s.u+P'; |
||
| 361 | |||
| 362 | /** |
||
| 363 | * Formating string for \DateTime::format() for date columns |
||
| 364 | * @var string |
||
| 365 | */ |
||
| 366 | static public $DateFormat = 'Y-m-d'; |
||
| 367 | |||
| 368 | /** |
||
| 369 | * Last Request response stats |
||
| 370 | * @var array |
||
| 371 | */ |
||
| 372 | protected $responseStats = null; |
||
| 373 | |||
| 374 | /** |
||
| 375 | * Chained Objects |
||
| 376 | * @var array |
||
| 377 | */ |
||
| 378 | public $chained = []; |
||
| 379 | |||
| 380 | /** |
||
| 381 | * We Connect to server by default |
||
| 382 | * @var boolean |
||
| 383 | */ |
||
| 384 | public $offline = false; |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Override cURL timeout |
||
| 388 | * @var int seconds |
||
| 389 | */ |
||
| 390 | public $timeout = null; |
||
| 391 | |||
| 392 | /** |
||
| 393 | * Columns Info for serveral evidencies |
||
| 394 | * @var array |
||
| 395 | */ |
||
| 396 | private $columnsInfo = []; |
||
| 397 | |||
| 398 | /** |
||
| 399 | * Throw Exception in case of FlexiBee error |
||
| 400 | * @var boolean |
||
| 401 | */ |
||
| 402 | public $throwException = false; |
||
| 403 | |||
| 404 | /** |
||
| 405 | * Class for read only interaction with FlexiBee. |
||
| 406 | * |
||
| 407 | * @param mixed $init default record id or initial data. See processInit() |
||
| 408 | * @param array $options Connection settings and other options override |
||
| 409 | */ |
||
| 410 | public function __construct($init = null, $options = []) { |
||
| 419 | |||
| 420 | /** |
||
| 421 | * Set internal Object name |
||
| 422 | * |
||
| 423 | * @param string $objectName |
||
| 424 | * |
||
| 425 | * @return string Jméno objektu |
||
| 426 | */ |
||
| 427 | public function setObjectName($objectName = null) { |
||
| 430 | |||
| 431 | /** |
||
| 432 | * SetUp Object to be ready for work |
||
| 433 | * |
||
| 434 | * @param array $options Object Options ( user,password,authSessionId |
||
| 435 | * company,url,evidence, |
||
| 436 | * prefix,defaultUrlParams,debug, |
||
| 437 | * detail,offline,filter,ignore404 |
||
| 438 | * timeout,companyUrl,ver,throwException |
||
| 439 | */ |
||
| 440 | public function setUp($options = []) { |
||
| 484 | |||
| 485 | /** |
||
| 486 | * Convert companyUrl provided by CustomButton to options array |
||
| 487 | * |
||
| 488 | * @param string $companyUrl |
||
| 489 | * |
||
| 490 | * @return array Options |
||
| 491 | */ |
||
| 492 | public static function companyUrlToOptions($companyUrl) { |
||
| 503 | |||
| 504 | /** |
||
| 505 | * Get Current connection options for use in another object |
||
| 506 | * |
||
| 507 | * @return array usable as second constructor parameter |
||
| 508 | */ |
||
| 509 | public function getConnectionOptions() { |
||
| 526 | |||
| 527 | /** |
||
| 528 | * Export current/given configutation into Environment |
||
| 529 | * @param array $opts |
||
| 530 | */ |
||
| 531 | public function configToEnv($opts = null) { |
||
| 549 | |||
| 550 | /** |
||
| 551 | * Inicializace CURL |
||
| 552 | * |
||
| 553 | * @return boolean Online Status |
||
| 554 | */ |
||
| 555 | public function curlInit() { |
||
| 576 | |||
| 577 | /** |
||
| 578 | * Initialise object with given data. Availble value types: |
||
| 579 | * |
||
| 580 | * * 234 - interní číslo záznamu k načtení |
||
| 581 | * * code:LOPATA - kód záznamu |
||
| 582 | * * BAGR - kód záznamu k načtení |
||
| 583 | * * ['id'=>24,'nazev'=>'hoblík'] - pole hodnot k předvyplnění |
||
| 584 | * * 743.json?relations=adresa,vazby - část url s parametry k načtení |
||
| 585 | * |
||
| 586 | * @param mixed $init číslo/"(code:)kód"/(část)URI záznamu k načtení | pole hodnot k předvyplnění |
||
| 587 | */ |
||
| 588 | public function processInit($init) { |
||
| 599 | |||
| 600 | /** |
||
| 601 | * Set Data Field value |
||
| 602 | * |
||
| 603 | * @param string $columnName field name |
||
| 604 | * @param mixed $value field data value |
||
| 605 | * |
||
| 606 | * @return bool Success |
||
| 607 | */ |
||
| 608 | public function setDataValue($columnName, $value) { |
||
| 634 | |||
| 635 | /** |
||
| 636 | * PHP Date object to FlexiBee date format |
||
| 637 | * |
||
| 638 | * @param \DateTime $date |
||
| 639 | */ |
||
| 640 | public static function dateToFlexiDate($date) { |
||
| 643 | |||
| 644 | /** |
||
| 645 | * PHP Date object to FlexiBee date format |
||
| 646 | * |
||
| 647 | * @param \DateTime $dateTime |
||
| 648 | */ |
||
| 649 | public static function dateToFlexiDateTime($dateTime) { |
||
| 652 | |||
| 653 | /** |
||
| 654 | * Set URL prefix |
||
| 655 | * |
||
| 656 | * @param string $prefix |
||
| 657 | */ |
||
| 658 | public function setPrefix($prefix) { |
||
| 678 | |||
| 679 | /** |
||
| 680 | * Set communication format. |
||
| 681 | * One of html|xml|json|csv|dbf|xls|isdoc|isdocx|edi|pdf|pdf|vcf|ical |
||
| 682 | * |
||
| 683 | * @param string $format |
||
| 684 | * |
||
| 685 | * @return boolean format is availble |
||
| 686 | */ |
||
| 687 | public function setFormat($format) { |
||
| 700 | |||
| 701 | /** |
||
| 702 | * Nastaví Evidenci pro Komunikaci. |
||
| 703 | * Set evidence for communication |
||
| 704 | * |
||
| 705 | * @param string $evidence evidence pathName to use |
||
| 706 | * |
||
| 707 | * @return boolean evidence switching status |
||
| 708 | */ |
||
| 709 | public function setEvidence($evidence) { |
||
| 734 | |||
| 735 | /** |
||
| 736 | * Vrací právě používanou evidenci pro komunikaci |
||
| 737 | * Obtain current used evidence |
||
| 738 | * |
||
| 739 | * @return string |
||
| 740 | */ |
||
| 741 | public function getEvidence() { |
||
| 744 | |||
| 745 | /** |
||
| 746 | * Set used company. |
||
| 747 | * Nastaví Firmu. |
||
| 748 | * |
||
| 749 | * @param string $company |
||
| 750 | */ |
||
| 751 | public function setCompany($company) { |
||
| 754 | |||
| 755 | /** |
||
| 756 | * Obtain company now used |
||
| 757 | * Vrací právě používanou firmu |
||
| 758 | * |
||
| 759 | * @return string |
||
| 760 | */ |
||
| 761 | public function getCompany() { |
||
| 764 | |||
| 765 | /** |
||
| 766 | * Vrací název evidence použité v odpovědích z FlexiBee |
||
| 767 | * |
||
| 768 | * @return string |
||
| 769 | */ |
||
| 770 | public function getResponseEvidence() { |
||
| 784 | |||
| 785 | /** |
||
| 786 | * Převede rekurzivně Objekt na pole. |
||
| 787 | * |
||
| 788 | * @param object|array $object |
||
| 789 | * |
||
| 790 | * @return array |
||
| 791 | */ |
||
| 792 | public static function object2array($object) { |
||
| 811 | |||
| 812 | /** |
||
| 813 | * Převede rekurzivně v poli všechny objekty na jejich identifikátory. |
||
| 814 | * |
||
| 815 | * @param object|array $object |
||
| 816 | * |
||
| 817 | * @return array |
||
| 818 | */ |
||
| 819 | public static function objectToID($object) { |
||
| 836 | |||
| 837 | /** |
||
| 838 | * Return basic URL for used Evidence |
||
| 839 | * |
||
| 840 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
| 841 | * |
||
| 842 | * @return string Evidence URL |
||
| 843 | */ |
||
| 844 | public function getEvidenceURL() { |
||
| 852 | |||
| 853 | /** |
||
| 854 | * Add suffix to Evidence URL |
||
| 855 | * |
||
| 856 | * @param string $urlSuffix |
||
| 857 | * |
||
| 858 | * @return string |
||
| 859 | */ |
||
| 860 | public function evidenceUrlWithSuffix($urlSuffix) { |
||
| 870 | |||
| 871 | /** |
||
| 872 | * Update $this->apiURL |
||
| 873 | */ |
||
| 874 | public function updateApiURL() { |
||
| 888 | |||
| 889 | /* |
||
| 890 | * Add Default Url params to given url if not overrided |
||
| 891 | * |
||
| 892 | * @param string $urlRaw |
||
| 893 | * |
||
| 894 | * @return string url with default params added |
||
| 895 | */ |
||
| 896 | |||
| 897 | public function addDefaultUrlParams($urlRaw) { |
||
| 901 | |||
| 902 | /** |
||
| 903 | * Funkce, která provede I/O operaci a vyhodnotí výsledek. |
||
| 904 | * |
||
| 905 | * @param string $urlSuffix část URL za identifikátorem firmy. |
||
| 906 | * @param string $method HTTP/REST metoda |
||
| 907 | * @param string $format Requested format |
||
| 908 | * |
||
| 909 | * @return array|boolean Výsledek operace |
||
| 910 | */ |
||
| 911 | public function performRequest($urlSuffix = null, $method = 'GET', |
||
| 931 | |||
| 932 | /** |
||
| 933 | * Parse Raw FlexiBee response in several formats |
||
| 934 | * |
||
| 935 | * @param string $responseRaw raw response body |
||
| 936 | * @param string $format Raw Response format json|xml|etc |
||
| 937 | * |
||
| 938 | * @return array |
||
| 939 | */ |
||
| 940 | public function rawResponseToArray($responseRaw, $format) { |
||
| 958 | |||
| 959 | /** |
||
| 960 | * Convert FlexiBee Response JSON to Array |
||
| 961 | * |
||
| 962 | * @param string $rawJson |
||
| 963 | * |
||
| 964 | * @return array |
||
| 965 | */ |
||
| 966 | public function rawJsonToArray($rawJson) { |
||
| 981 | |||
| 982 | /** |
||
| 983 | * Convert FlexiBee Response XML to Array |
||
| 984 | * |
||
| 985 | * @param string $rawXML |
||
| 986 | * |
||
| 987 | * @return array |
||
| 988 | */ |
||
| 989 | public function rawXmlToArray($rawXML) { |
||
| 992 | |||
| 993 | /** |
||
| 994 | * Parse Response array |
||
| 995 | * |
||
| 996 | * @param array $responseDecoded |
||
| 997 | * @param int $responseCode Request Response Code |
||
| 998 | * |
||
| 999 | * @return array main data part of response |
||
| 1000 | */ |
||
| 1001 | public function parseResponse($responseDecoded, $responseCode) { |
||
| 1069 | |||
| 1070 | /** |
||
| 1071 | * Parse error message response |
||
| 1072 | * |
||
| 1073 | * @param array $responseDecoded |
||
| 1074 | * |
||
| 1075 | * @return int number of errors processed |
||
| 1076 | */ |
||
| 1077 | public function parseError(array $responseDecoded) { |
||
| 1085 | |||
| 1086 | /** |
||
| 1087 | * Vykonej HTTP požadavek |
||
| 1088 | * |
||
| 1089 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
| 1090 | * @param string $url URL požadavku |
||
| 1091 | * @param string $method HTTP Method GET|POST|PUT|OPTIONS|DELETE |
||
| 1092 | * @param string $format požadovaný formát komunikace |
||
| 1093 | * |
||
| 1094 | * @return int HTTP Response CODE |
||
| 1095 | */ |
||
| 1096 | public function doCurlRequest($url, $method, $format = null) { |
||
| 1139 | |||
| 1140 | /** |
||
| 1141 | * Obtain json for application/json |
||
| 1142 | * |
||
| 1143 | * @param string $contentType |
||
| 1144 | * @param string $url |
||
| 1145 | * |
||
| 1146 | * @return string response format |
||
| 1147 | */ |
||
| 1148 | public function contentTypeToResponseFormat($contentType, $url = null) { |
||
| 1175 | |||
| 1176 | /** |
||
| 1177 | * Nastaví druh prováděné akce. |
||
| 1178 | * |
||
| 1179 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
| 1180 | * @param string $action |
||
| 1181 | * |
||
| 1182 | * @return boolean |
||
| 1183 | */ |
||
| 1184 | public function setAction($action) { |
||
| 1194 | |||
| 1195 | /** |
||
| 1196 | * Convert XML to array. |
||
| 1197 | * |
||
| 1198 | * @param string $xml |
||
| 1199 | * |
||
| 1200 | * @return array |
||
| 1201 | */ |
||
| 1202 | public static function xml2array($xml) { |
||
| 1221 | |||
| 1222 | /** |
||
| 1223 | * Odpojení od FlexiBee. |
||
| 1224 | */ |
||
| 1225 | public function disconnect() { |
||
| 1231 | |||
| 1232 | /** |
||
| 1233 | * Disconnect CURL befere pass away |
||
| 1234 | */ |
||
| 1235 | public function __destruct() { |
||
| 1238 | |||
| 1239 | /** |
||
| 1240 | * Načte řádek dat z FlexiBee. |
||
| 1241 | * |
||
| 1242 | * @param int $recordID id požadovaného záznamu |
||
| 1243 | * |
||
| 1244 | * @return array |
||
| 1245 | */ |
||
| 1246 | public function getFlexiRow($recordID) { |
||
| 1255 | |||
| 1256 | /** |
||
| 1257 | * Oddělí z pole podmínek ty jenž patří za ? v URL požadavku |
||
| 1258 | * |
||
| 1259 | * @link https://www.flexibee.eu/api/dokumentace/ref/urls/ Sestavování URL |
||
| 1260 | * @param array $conditions pole podmínek - rendrují se do () |
||
| 1261 | * @param array $urlParams pole parametrů - rendrují za ? |
||
| 1262 | */ |
||
| 1263 | public function extractUrlParams(&$conditions, &$urlParams) { |
||
| 1270 | |||
| 1271 | /** |
||
| 1272 | * convert unicode to entities for use with FlexiBee queries |
||
| 1273 | * |
||
| 1274 | * @param string $urlRaw |
||
| 1275 | * |
||
| 1276 | * @return string |
||
| 1277 | */ |
||
| 1278 | public static function urlEncode($urlRaw) { |
||
| 1281 | |||
| 1282 | /** |
||
| 1283 | * Načte data z FlexiBee. |
||
| 1284 | * |
||
| 1285 | * @param string $suffix dotaz |
||
| 1286 | * @param string|array $conditions Custom filters or modifiers |
||
| 1287 | * |
||
| 1288 | * @return array Data obtained |
||
| 1289 | */ |
||
| 1290 | public function getFlexiData($suffix = null, $conditions = null) { |
||
| 1356 | |||
| 1357 | /** |
||
| 1358 | * Načte záznam z FlexiBee a uloží v sobě jeho data |
||
| 1359 | * Read FlexiBee record and store it inside od object |
||
| 1360 | * |
||
| 1361 | * @param int|string $id ID or conditions |
||
| 1362 | * |
||
| 1363 | * @return int počet načtených položek |
||
| 1364 | */ |
||
| 1365 | public function loadFromFlexiBee($id = null) { |
||
| 1379 | |||
| 1380 | /** |
||
| 1381 | * Reload current record from FlexiBee |
||
| 1382 | * |
||
| 1383 | * @return boolean |
||
| 1384 | */ |
||
| 1385 | public function reload() { |
||
| 1391 | |||
| 1392 | /** |
||
| 1393 | * Set Filter code for requests |
||
| 1394 | * |
||
| 1395 | * @link https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
| 1396 | * |
||
| 1397 | * @param array|string $filter filter formula or ['key'=>'value'] |
||
| 1398 | * |
||
| 1399 | * @return string Filter code |
||
| 1400 | */ |
||
| 1401 | public function setFilter($filter) { |
||
| 1404 | |||
| 1405 | /** |
||
| 1406 | * Převede data do Json formátu pro FlexiBee. |
||
| 1407 | * Convert data to FlexiBee like Json format |
||
| 1408 | * |
||
| 1409 | * @url https://www.flexibee.eu/api/dokumentace/ref/actions/ |
||
| 1410 | * @url https://www.flexibee.eu/api/dokumentace/ref/zamykani-odemykani/ |
||
| 1411 | * |
||
| 1412 | * @param array $data object data |
||
| 1413 | * @param int $options json_encode options like JSON_PRETTY_PRINT etc |
||
| 1414 | * |
||
| 1415 | * @return string |
||
| 1416 | */ |
||
| 1417 | public function getJsonizedData($data = null, $options = 0) { |
||
| 1429 | |||
| 1430 | /** |
||
| 1431 | * Get Data Fragment specific for current object |
||
| 1432 | * |
||
| 1433 | * @param array $data |
||
| 1434 | * |
||
| 1435 | * @return array |
||
| 1436 | */ |
||
| 1437 | public function getDataForJSON($data = null) { |
||
| 1479 | |||
| 1480 | /** |
||
| 1481 | * Join another FlexiPeeHP Object |
||
| 1482 | * |
||
| 1483 | * @param FlexiBeeRO $object |
||
| 1484 | * |
||
| 1485 | * @return boolean adding to stack success |
||
| 1486 | */ |
||
| 1487 | public function join(&$object) { |
||
| 1497 | |||
| 1498 | /** |
||
| 1499 | * Prepare record ID to use in URL |
||
| 1500 | * |
||
| 1501 | * @param mixed $id |
||
| 1502 | * |
||
| 1503 | * @return string id ready for use in URL |
||
| 1504 | */ |
||
| 1505 | public static function urlizeId($id) { |
||
| 1515 | |||
| 1516 | /** |
||
| 1517 | * Test if given record ID exists in FlexiBee. |
||
| 1518 | * |
||
| 1519 | * @param mixed $identifer presence state |
||
| 1520 | * |
||
| 1521 | * @return boolean |
||
| 1522 | */ |
||
| 1523 | public function idExists($identifer = null) { |
||
| 1537 | |||
| 1538 | /** |
||
| 1539 | * Test if given record exists in FlexiBee. |
||
| 1540 | * |
||
| 1541 | * @param array|string|int $data ext:id:23|code:ITEM|['id'=>23]|23 |
||
| 1542 | * |
||
| 1543 | * @return boolean Record presence status |
||
| 1544 | */ |
||
| 1545 | public function recordExists($data = []) { |
||
| 1564 | |||
| 1565 | /** |
||
| 1566 | * Vrací z FlexiBee sloupečky podle podmínek. |
||
| 1567 | * |
||
| 1568 | * @param array|int|string $conditions pole podmínek nebo ID záznamu |
||
| 1569 | * @param string $indexBy klice vysledku naplnit hodnotou ze |
||
| 1570 | * sloupečku |
||
| 1571 | * @return array |
||
| 1572 | */ |
||
| 1573 | public function getAllFromFlexibee($conditions = null, $indexBy = null) { |
||
| 1586 | |||
| 1587 | /** |
||
| 1588 | * Vrací z FlexiBee sloupečky podle podmínek. |
||
| 1589 | * |
||
| 1590 | * @param string|string[] $columnsList seznam položek nebo úrověň detailu: id|summary|full |
||
| 1591 | * @param array $conditions pole podmínek nebo ID záznamu |
||
| 1592 | * @param string $indexBy Sloupeček podle kterého indexovat záznamy |
||
| 1593 | * |
||
| 1594 | * @return array |
||
| 1595 | */ |
||
| 1596 | public function getColumnsFromFlexibee($columnsList, $conditions = [], |
||
| 1634 | |||
| 1635 | /** |
||
| 1636 | * Vrací kód záznamu. |
||
| 1637 | * Obtain record CODE |
||
| 1638 | * |
||
| 1639 | * @param mixed $data |
||
| 1640 | * |
||
| 1641 | * @return string |
||
| 1642 | */ |
||
| 1643 | public function getKod($data = null, $unique = true) { |
||
| 1696 | |||
| 1697 | /** |
||
| 1698 | * Write Operation Result. |
||
| 1699 | * |
||
| 1700 | * @param array $resultData |
||
| 1701 | * @param string $url URL |
||
| 1702 | * |
||
| 1703 | * @return boolean Log save success |
||
| 1704 | */ |
||
| 1705 | public function logResult($resultData = null, $url = null) { |
||
| 1750 | |||
| 1751 | /** |
||
| 1752 | * Save RAW Curl Request & Response to files in Temp directory |
||
| 1753 | */ |
||
| 1754 | public function saveDebugFiles() { |
||
| 1767 | |||
| 1768 | /** |
||
| 1769 | * Připraví data pro odeslání do FlexiBee |
||
| 1770 | * |
||
| 1771 | * @param string $data |
||
| 1772 | */ |
||
| 1773 | public function setPostFields($data) { |
||
| 1776 | |||
| 1777 | /** |
||
| 1778 | * Get Content ready to be send as POST body |
||
| 1779 | * @return string |
||
| 1780 | */ |
||
| 1781 | public function getPostFields() { |
||
| 1784 | |||
| 1785 | /** |
||
| 1786 | * Generuje fragment url pro filtrování. |
||
| 1787 | * |
||
| 1788 | * @see https://www.flexibee.eu/api/dokumentace/ref/filters |
||
| 1789 | * |
||
| 1790 | * @param array $data key=>values; value can bee class DatePeriod, DateTime or Array |
||
| 1791 | * @param string $joiner default and/or |
||
| 1792 | * @param string $defop default operator |
||
| 1793 | * |
||
| 1794 | * @return string |
||
| 1795 | */ |
||
| 1796 | public static function flexiUrl(array $data, $joiner = 'and', $defop = 'eq') { |
||
| 1879 | |||
| 1880 | /** |
||
| 1881 | * Obtain record/object numeric identificator id: |
||
| 1882 | * Vrací číselný identifikátor objektu id: |
||
| 1883 | * |
||
| 1884 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
| 1885 | * |
||
| 1886 | * @return null|int indentifikátor záznamu reprezentovaného objektem |
||
| 1887 | */ |
||
| 1888 | public function getRecordID() { |
||
| 1892 | |||
| 1893 | /** |
||
| 1894 | * Obtain record/object identificator code: |
||
| 1895 | * Vrací identifikátor objektu code: |
||
| 1896 | * |
||
| 1897 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
| 1898 | * |
||
| 1899 | * @return string record code identifier |
||
| 1900 | */ |
||
| 1901 | public function getRecordCode() { |
||
| 1904 | |||
| 1905 | /** |
||
| 1906 | * Obtain record/object identificator extId: code: or id: |
||
| 1907 | * Vrací identifikátor objektu extId: code: nebo id: |
||
| 1908 | * |
||
| 1909 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
| 1910 | * |
||
| 1911 | * @return string|int|null record code identifier |
||
| 1912 | */ |
||
| 1913 | public function getRecordIdent() { |
||
| 1923 | |||
| 1924 | /** |
||
| 1925 | * Obtain record/object identificator code: or id: |
||
| 1926 | * Vrací identifikátor objektu code: nebo id: |
||
| 1927 | * |
||
| 1928 | * @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů |
||
| 1929 | * |
||
| 1930 | * @return string indentifikátor záznamu reprezentovaného objektem |
||
| 1931 | */ |
||
| 1932 | public function __toString() { |
||
| 1935 | |||
| 1936 | /** |
||
| 1937 | * Gives you FlexiPeeHP class name for Given Evidence |
||
| 1938 | * |
||
| 1939 | * @param string $evidence |
||
| 1940 | * |
||
| 1941 | * @return string Class name |
||
| 1942 | */ |
||
| 1943 | public static function evidenceToClassName($evidence) { |
||
| 1946 | |||
| 1947 | /** |
||
| 1948 | * Obtain ID of first record in evidence |
||
| 1949 | * |
||
| 1950 | * @return string|null id or null if no records |
||
| 1951 | */ |
||
| 1952 | public function getFirstRecordID() { |
||
| 1962 | |||
| 1963 | /** |
||
| 1964 | * Get previous record ID |
||
| 1965 | * |
||
| 1966 | * @param array $conditions optional |
||
| 1967 | * |
||
| 1968 | * @return int|null |
||
| 1969 | */ |
||
| 1970 | public function getNextRecordID($conditions = []) { |
||
| 1978 | |||
| 1979 | /** |
||
| 1980 | * Get next record ID |
||
| 1981 | * |
||
| 1982 | * @param array $conditions optional |
||
| 1983 | * |
||
| 1984 | * @return int|null |
||
| 1985 | */ |
||
| 1986 | public function getPrevRecordID($conditions = []) { |
||
| 1994 | |||
| 1995 | /** |
||
| 1996 | * Vrací hodnotu daného externího ID |
||
| 1997 | * |
||
| 1998 | * @param string $want Namespace Selector. If empty,you obtain the first one. |
||
| 1999 | * |
||
| 2000 | * @return string|array one id or array if multiplete |
||
| 2001 | */ |
||
| 2002 | public function getExternalID($want = null) { |
||
| 2029 | |||
| 2030 | /** |
||
| 2031 | * gives you currently loaded extermal IDs |
||
| 2032 | * |
||
| 2033 | * @return array |
||
| 2034 | */ |
||
| 2035 | public function getExternalIDs() { |
||
| 2038 | |||
| 2039 | /** |
||
| 2040 | * Obtain actual GlobalVersion |
||
| 2041 | * Vrací aktuální globální verzi změn |
||
| 2042 | * |
||
| 2043 | * @link https://www.flexibee.eu/api/dokumentace/ref/changes-api#globalVersion Globální Verze |
||
| 2044 | * |
||
| 2045 | * @return int |
||
| 2046 | */ |
||
| 2047 | public function getGlobalVersion() { |
||
| 2052 | |||
| 2053 | /** |
||
| 2054 | * Gives you current ApiURL with given format suffix |
||
| 2055 | * |
||
| 2056 | * @param string $format json|html|xml|... |
||
| 2057 | * |
||
| 2058 | * @return string API URL for current record or object/evidence |
||
| 2059 | */ |
||
| 2060 | public function getApiURL($format = null) { |
||
| 2064 | |||
| 2065 | /** |
||
| 2066 | * Obtain content type of last response |
||
| 2067 | * |
||
| 2068 | * @return string |
||
| 2069 | */ |
||
| 2070 | public function getResponseFormat() { |
||
| 2073 | |||
| 2074 | /** |
||
| 2075 | * Return the same response format for one and multiplete results |
||
| 2076 | * |
||
| 2077 | * @param array $responseBody |
||
| 2078 | * |
||
| 2079 | * @return array |
||
| 2080 | */ |
||
| 2081 | public function unifyResponseFormat($responseBody) { |
||
| 2109 | |||
| 2110 | /** |
||
| 2111 | * Obtain structure for current (or given) evidence |
||
| 2112 | * |
||
| 2113 | * @param string $evidence |
||
| 2114 | * |
||
| 2115 | * @return array Evidence structure |
||
| 2116 | */ |
||
| 2117 | public function getOfflineColumnsInfo($evidence = null) { |
||
| 2125 | |||
| 2126 | /** |
||
| 2127 | * Obtain Current evidence Live structure |
||
| 2128 | * |
||
| 2129 | * @param string $evidence |
||
| 2130 | * |
||
| 2131 | * @return array structure |
||
| 2132 | */ |
||
| 2133 | public function getOnlineColumnsInfo($evidence = null) { |
||
| 2153 | |||
| 2154 | /** |
||
| 2155 | * Update evidence info from array or online from properties.json or offline |
||
| 2156 | * |
||
| 2157 | * @param array $columnsInfo |
||
| 2158 | * @param string $evidence |
||
| 2159 | */ |
||
| 2160 | public function updateColumnsInfo($columnsInfo = null, $evidence = null) { |
||
| 2168 | |||
| 2169 | /** |
||
| 2170 | * Gives you evidence structure. You can obtain current online by pre-calling: |
||
| 2171 | * $this->updateColumnsInfo($evidence, $this->getOnlineColumnsInfo($evidence)); |
||
| 2172 | * |
||
| 2173 | * @param string $evidence |
||
| 2174 | * |
||
| 2175 | * @return array |
||
| 2176 | */ |
||
| 2177 | public function getColumnsInfo($evidence = null) { |
||
| 2185 | |||
| 2186 | /** |
||
| 2187 | * Gives you properties for (current) evidence column |
||
| 2188 | * |
||
| 2189 | * @param string $column name of column |
||
| 2190 | * @param string $evidence evidence name if different |
||
| 2191 | * |
||
| 2192 | * @return array column properties or null if column not exits |
||
| 2193 | */ |
||
| 2194 | public function getColumnInfo($column, $evidence = null) { |
||
| 2198 | |||
| 2199 | /** |
||
| 2200 | * Obtain actions for current (or given) evidence |
||
| 2201 | * |
||
| 2202 | * @param string $evidence |
||
| 2203 | * |
||
| 2204 | * @return array Evidence structure |
||
| 2205 | */ |
||
| 2206 | public function getActionsInfo($evidence = null) { |
||
| 2217 | |||
| 2218 | /** |
||
| 2219 | * Obtain relations for current (or given) evidence |
||
| 2220 | * |
||
| 2221 | * @param string $evidence |
||
| 2222 | * |
||
| 2223 | * @return array Evidence structure |
||
| 2224 | */ |
||
| 2225 | public function getRelationsInfo($evidence = null) { |
||
| 2236 | |||
| 2237 | /** |
||
| 2238 | * Obtain info for current (or given) evidence |
||
| 2239 | * |
||
| 2240 | * @param string $evidence |
||
| 2241 | * |
||
| 2242 | * @return array Evidence info |
||
| 2243 | */ |
||
| 2244 | public function getEvidenceInfo($evidence = null) { |
||
| 2258 | |||
| 2259 | /** |
||
| 2260 | * Obtain name for current (or given) evidence path |
||
| 2261 | * |
||
| 2262 | * @param string $evidence Evidence Path |
||
| 2263 | * |
||
| 2264 | * @return array Evidence info |
||
| 2265 | */ |
||
| 2266 | public function getEvidenceName($evidence = null) { |
||
| 2276 | |||
| 2277 | /** |
||
| 2278 | * Save current object to file |
||
| 2279 | * |
||
| 2280 | * @param string $destfile path to file |
||
| 2281 | */ |
||
| 2282 | public function saveResponseToFile($destfile) { |
||
| 2288 | |||
| 2289 | /** |
||
| 2290 | * Obtain established relations listing |
||
| 2291 | * |
||
| 2292 | * @return array Null or Relations |
||
| 2293 | */ |
||
| 2294 | public function getVazby($id = null) { |
||
| 2307 | |||
| 2308 | /** |
||
| 2309 | * Gives You URL for Current Record in FlexiBee web interface |
||
| 2310 | * |
||
| 2311 | * @return string url |
||
| 2312 | */ |
||
| 2313 | public function getFlexiBeeURL() { |
||
| 2324 | |||
| 2325 | /** |
||
| 2326 | * Set Record Key |
||
| 2327 | * |
||
| 2328 | * @param int|string $myKeyValue |
||
| 2329 | * |
||
| 2330 | * @return boolean |
||
| 2331 | */ |
||
| 2332 | public function setMyKey($myKeyValue) { |
||
| 2354 | |||
| 2355 | /** |
||
| 2356 | * Set or get ignore not found pages flag |
||
| 2357 | * |
||
| 2358 | * @param boolean $ignore set flag to |
||
| 2359 | * |
||
| 2360 | * @return boolean get flag state |
||
| 2361 | */ |
||
| 2362 | public function ignore404($ignore = null) { |
||
| 2368 | |||
| 2369 | /** |
||
| 2370 | * Send Document by mail |
||
| 2371 | * |
||
| 2372 | * @url https://www.flexibee.eu/api/dokumentace/ref/odesilani-mailem/ |
||
| 2373 | * |
||
| 2374 | * @param string $to Email ecipient |
||
| 2375 | * @param string $subject Email Subject |
||
| 2376 | * @param string $body Email Text |
||
| 2377 | * |
||
| 2378 | * @return boolean mail sent status |
||
| 2379 | */ |
||
| 2380 | public function sendByMail($to, $subject, $body, $cc = null) { |
||
| 2388 | |||
| 2389 | /** |
||
| 2390 | * FlexiBee date to PHP DateTime conversion |
||
| 2391 | * |
||
| 2392 | * @param string $flexidate 2017-05-26 or 2017-05-26+02:00 |
||
| 2393 | * |
||
| 2394 | * @return \DateTime | false |
||
| 2395 | */ |
||
| 2396 | public static function flexiDateToDateTime($flexidate) { |
||
| 2399 | |||
| 2400 | /** |
||
| 2401 | * FlexiBee dateTime to PHP DateTime conversion |
||
| 2402 | * |
||
| 2403 | * @param string $flexidatetime 2017-09-26T10:00:53.755+02:00 or older 2017-05-19T00:00:00+02:00 |
||
| 2404 | * |
||
| 2405 | * @return \DateTime | false |
||
| 2406 | */ |
||
| 2407 | public static function flexiDateTimeToDateTime($flexidatetime) { |
||
| 2415 | |||
| 2416 | /** |
||
| 2417 | * Získá dokument v daném formátu |
||
| 2418 | * Obtain document in given format |
||
| 2419 | * |
||
| 2420 | * @link https://www.flexibee.eu/api/dokumentace/ref/pdf/ PDF Exports |
||
| 2421 | * |
||
| 2422 | * @param string $format pdf/csv/xml/json/ ... |
||
| 2423 | * @param string $reportName Template used to generate PDF |
||
| 2424 | * @param string $lang cs|sk|en|de Template language used to generate PDF |
||
| 2425 | * @param boolean $sign sign resulting PDF by certificate ? |
||
| 2426 | * |
||
| 2427 | * @return string|null filename downloaded or none |
||
| 2428 | */ |
||
| 2429 | public function getInFormat($format, $reportName = null, $lang = null, |
||
| 2468 | |||
| 2469 | /** |
||
| 2470 | * Uloží dokument v daném formátu do složky v systému souborů |
||
| 2471 | * Save document in given format to directory in filesystem |
||
| 2472 | * |
||
| 2473 | * @param string $format pdf/csv/xml/json/ ... |
||
| 2474 | * @param string $destDir where to put file (prefix) |
||
| 2475 | * @param string $reportName Template used to generate PDF |
||
| 2476 | * |
||
| 2477 | * @return string|null filename downloaded or none |
||
| 2478 | */ |
||
| 2479 | public function downloadInFormat($format, $destDir = './', |
||
| 2494 | |||
| 2495 | /** |
||
| 2496 | * Take data for object. separate external IDs |
||
| 2497 | * |
||
| 2498 | * @param array $data Data to keep |
||
| 2499 | * |
||
| 2500 | * @return int number of records taken |
||
| 2501 | */ |
||
| 2502 | public function takeData($data) { |
||
| 2523 | |||
| 2524 | /** |
||
| 2525 | * Get Current Evidence reports listing |
||
| 2526 | * |
||
| 2527 | * @link https://www.flexibee.eu/api/dokumentace/casto-kladene-dotazy-pro-api/vyber-reportu-do-pdf/ Výběr reportu do PDF |
||
| 2528 | * |
||
| 2529 | * @return array |
||
| 2530 | */ |
||
| 2531 | public function getReportsInfo() { |
||
| 2545 | |||
| 2546 | /** |
||
| 2547 | * Request authSessionId from current server |
||
| 2548 | * |
||
| 2549 | * @link https://www.flexibee.eu/api/dokumentace/ref/login/ description |
||
| 2550 | * |
||
| 2551 | * @param string $username |
||
| 2552 | * @param string $password |
||
| 2553 | * @param string $otp optional onetime password |
||
| 2554 | * |
||
| 2555 | * @return string authUserId or null in case of problems |
||
| 2556 | */ |
||
| 2557 | public function requestAuthSessionID($username, $password, $otp = null) { |
||
| 2570 | |||
| 2571 | /** |
||
| 2572 | * Try to Sign in current user to FlexiBee and keep authSessionId |
||
| 2573 | * |
||
| 2574 | * @return boolean sign in success |
||
| 2575 | */ |
||
| 2576 | public function login() { |
||
| 2581 | |||
| 2582 | /** |
||
| 2583 | * End (current's user) session |
||
| 2584 | * |
||
| 2585 | * |
||
| 2586 | * @link https://www.flexibee.eu/api/dokumentace/ref/logout Logout Reference |
||
| 2587 | * |
||
| 2588 | * @param string $username force username to sign off |
||
| 2589 | * |
||
| 2590 | * @return array server response |
||
| 2591 | */ |
||
| 2592 | public function logout($username = null) { |
||
| 2595 | |||
| 2596 | /** |
||
| 2597 | * Compile and send Report about Error500 to FlexiBee developers |
||
| 2598 | * If FlexiBee is running on localost try also include java backtrace |
||
| 2599 | * |
||
| 2600 | * @param array $errorResponse result of parseError(); |
||
| 2601 | */ |
||
| 2602 | public function error500Reporter($errorResponse) { |
||
| 2666 | |||
| 2667 | /** |
||
| 2668 | * Returns code:CODE |
||
| 2669 | * |
||
| 2670 | * @param string $code |
||
| 2671 | * |
||
| 2672 | * @return string |
||
| 2673 | */ |
||
| 2674 | public static function code($code) { |
||
| 2677 | |||
| 2678 | /** |
||
| 2679 | * Returns CODE without code: prefix |
||
| 2680 | * |
||
| 2681 | * @param string $code |
||
| 2682 | * |
||
| 2683 | * @return string |
||
| 2684 | */ |
||
| 2685 | public static function uncode($code) { |
||
| 2688 | |||
| 2689 | /** |
||
| 2690 | * Remove all @ items from array |
||
| 2691 | * |
||
| 2692 | * @param array $data original data |
||
| 2693 | * |
||
| 2694 | * @return array data without @ columns |
||
| 2695 | */ |
||
| 2696 | public static function arrayCleanUP($data) { |
||
| 2703 | |||
| 2704 | /** |
||
| 2705 | * Add Info about used user, server and libraries |
||
| 2706 | * |
||
| 2707 | * @param string $prefix banner prefix text |
||
| 2708 | * @param string $suffix banner suffix text |
||
| 2709 | */ |
||
| 2710 | public function logBanner($prefix = null, $suffix = null) { |
||
| 2717 | |||
| 2718 | /** |
||
| 2719 | * Get Last operation type |
||
| 2720 | * |
||
| 2721 | * @return string create|read|update|delete or update,insert for some inserted and updated in one transaction |
||
| 2722 | */ |
||
| 2723 | public function getLastOperationType() { |
||
| 2726 | |||
| 2727 | /** |
||
| 2728 | * Last operation errors |
||
| 2729 | * |
||
| 2730 | * @return array FlexiBee error meassages |
||
| 2731 | */ |
||
| 2732 | public function getErrors() { |
||
| 2735 | |||
| 2736 | /** |
||
| 2737 | * Reconnect After unserialization |
||
| 2738 | */ |
||
| 2739 | public function __wakeup() { |
||
| 2742 | |||
| 2743 | } |
||
| 2744 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.