for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace smtech\StMarksSearch\Canvas\Courses;
use Exception;
use smtech\CanvasPest\CanvasPest;
use smtech\StMarksSearch\Canvas\AbstractCanvasSearchDomain;
/**
* Parent object for Canvas course searches
*
* @author Seth Battis <[email protected]>
*/
abstract class AbstractCourseSearchDomain extends AbstractCanvasSearchDomain
{
* Localize the general Canvas URL to a particular course (if necessary)
* Will "localize" the `url` parameter after initialization -- i.e. if the
* URL of the search domain is `https://canvas.instructure.com` and the ID
* is 43, the URL will be localized to
* `https://canvas.instructure.com/courses/43`
* @return void
protected function localizeUrl()
if (!preg_match('%.*/courses/\d+$%', $this->getUrl())) {
$id = $this->getId();
if (!is_numeric($id)) {
$course = $this->getApi()->get("/courses/$id");
assert(isset($course['id']), new Exception("Unknown course `id` parameter: $id"));
$id = $course['id'];
}
$this->setUrl($this->getUrl() . "/courses/{$id}");